Skip to content

Commit

Permalink
refactor: move existing api to legacy dir (#670)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt authored Feb 12, 2024
1 parent 551c446 commit 4d4ac4c
Show file tree
Hide file tree
Showing 16 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion examples/other-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* It's possible to use a middleware to pre-process any request or handle raw response.
*/

import type { RequestMiddleware, ResponseMiddleware } from '../src/entrypoints/main.js'
import { GraphQLClient } from '../src/entrypoints/main.js'
import type { RequestMiddleware, ResponseMiddleware } from '../src/helpers/types.js'

const endpoint = `https://api.spacex.land/graphql/`

Expand Down
24 changes: 12 additions & 12 deletions src/entrypoints/main.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { ClientError } from '../classes/ClientError.js'
import { ClientError } from '../legacy/classes/ClientError.js'
import {
type BatchRequestDocument,
type BatchRequestsExtendedOptions,
type BatchRequestsOptions,
} from '../functions/batchRequests.js'
import { RequestExtendedOptions } from '../functions/request.js'
import { request } from '../functions/request.js'
import type { GraphQLResponse, RequestMiddleware, ResponseMiddleware } from '../helpers/types.js'
import { RawRequestOptions, RequestDocument, RequestOptions, Variables } from '../helpers/types.js'
export { GraphQLClient } from '../classes/GraphQLClient.js'
export { batchRequests } from '../functions/batchRequests.js'
export { gql } from '../functions/gql.js'
export { rawRequest } from '../functions/rawRequest.js'
export { analyzeDocument } from '../helpers/analyzeDocument.js'
export { GraphQLWebSocketClient } from '../lib/graphql-ws.js'
} from '../legacy/functions/batchRequests.js'
import { RequestExtendedOptions } from '../legacy/functions/request.js'
import { request } from '../legacy/functions/request.js'
import type { GraphQLResponse, RequestMiddleware, ResponseMiddleware } from '../legacy/helpers/types.js'
import { RawRequestOptions, RequestDocument, RequestOptions, Variables } from '../legacy/helpers/types.js'
export { GraphQLClient } from '../legacy/classes/GraphQLClient.js'
export { batchRequests } from '../legacy/functions/batchRequests.js'
export { gql } from '../legacy/functions/gql.js'
export { rawRequest } from '../legacy/functions/rawRequest.js'
export { analyzeDocument } from '../legacy/helpers/analyzeDocument.js'
export { GraphQLWebSocketClient } from '../legacy/lib/graphql-ws.js'
export {
BatchRequestDocument,
BatchRequestsExtendedOptions,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { callOrIdentity, HeadersInitToPlainObject } from '../../lib/prelude.js'
import type { BatchRequestDocument, BatchRequestsOptions, BatchResult } from '../functions/batchRequests.js'
import { parseBatchRequestArgs } from '../functions/batchRequests.js'
import { parseRawRequestArgs } from '../functions/rawRequest.js'
Expand All @@ -11,7 +12,6 @@ import {
type RequestConfig,
type Variables,
} from '../helpers/types.js'
import { callOrIdentity, HeadersInitToPlainObject } from '../lib/prelude.js'
import type { TypedDocumentNode } from '@graphql-typed-document-node/core'

/**
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { tryCatch } from '../../lib/prelude.js'
import { isOperationDefinitionNode } from '../lib/graphql.js'
import { tryCatch } from '../lib/prelude.js'
import type { RequestDocument } from './types.js'
/**
* Refactored imports from `graphql` to be more specific, this helps import only the required files (100KiB)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ACCEPT_HEADER, CONTENT_TYPE_GQL, CONTENT_TYPE_HEADER, CONTENT_TYPE_JSON } from '../../lib/http.js'
import { casesExhausted, uppercase, zip } from '../../lib/prelude.js'
import { ClientError } from '../classes/ClientError.js'
import type { GraphQLExecutionResultSingle } from '../lib/graphql.js'
import {
Expand All @@ -6,8 +8,6 @@ import {
isRequestResultHaveErrors,
parseGraphQLExecutionResult,
} from '../lib/graphql.js'
import { ACCEPT_HEADER, CONTENT_TYPE_GQL, CONTENT_TYPE_HEADER, CONTENT_TYPE_JSON } from '../lib/http.js'
import { casesExhausted, uppercase, zip } from '../lib/prelude.js'
import { defaultJsonSerializer } from './defaultJsonSerializer.js'
import type {
BatchVariables,
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/types.ts → src/legacy/helpers/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { MaybeLazy, RemoveIndex } from '../../lib/prelude.js'
import type { ClientError } from '../classes/ClientError.js'
import type { MaybeLazy, RemoveIndex } from '../lib/prelude.js'
import type { TypedDocumentNode } from '@graphql-typed-document-node/core'
import type { GraphQLError } from 'graphql/error/GraphQLError.js'
import type { DocumentNode } from 'graphql/language/ast.js'
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/lib/graphql.ts → src/legacy/lib/graphql.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CONTENT_TYPE_GQL, CONTENT_TYPE_JSON } from './http.js'
import { isPlainObject } from './prelude.js'
import { CONTENT_TYPE_GQL, CONTENT_TYPE_JSON } from '../../lib/http.js'
import { isPlainObject } from '../../lib/prelude.js'
import { Kind } from 'graphql'
/**
* Refactored imports from `graphql` to be more specific, this helps import only the required files (100KiB)
Expand Down
2 changes: 1 addition & 1 deletion tests/httpMethod.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { gql, GraphQLClient } from '../src/entrypoints/main.js'
import type { RequestConfig } from '../src/helpers/types.js'
import type { RequestConfig } from '../src/legacy/helpers/types.js'
import { CONTENT_TYPE_HEADER, statusCodes } from '../src/lib/http.js'
import { expect, test, vitest } from 'vitest'

Expand Down
2 changes: 1 addition & 1 deletion tests/json-serializer.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GraphQLClient } from '../src/entrypoints/main.js'
import type { Fetch, Variables } from '../src/helpers/types.js'
import type { Fetch, Variables } from '../src/legacy/helpers/types.js'
import { CONTENT_TYPE_HEADER, statusCodes } from '../src/lib/http.js'
import { setupMockServer } from './__helpers.js'
import { beforeEach, describe, expect, test, vitest } from 'vitest'
Expand Down

0 comments on commit 4d4ac4c

Please sign in to comment.