Skip to content

Commit 4d4ac4c

Browse files
authored
refactor: move existing api to legacy dir (#670)
1 parent 551c446 commit 4d4ac4c

16 files changed

+22
-22
lines changed

examples/other-middleware.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* It's possible to use a middleware to pre-process any request or handle raw response.
33
*/
44

5+
import type { RequestMiddleware, ResponseMiddleware } from '../src/entrypoints/main.js'
56
import { GraphQLClient } from '../src/entrypoints/main.js'
6-
import type { RequestMiddleware, ResponseMiddleware } from '../src/helpers/types.js'
77

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

src/entrypoints/main.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import { ClientError } from '../classes/ClientError.js'
1+
import { ClientError } from '../legacy/classes/ClientError.js'
22
import {
33
type BatchRequestDocument,
44
type BatchRequestsExtendedOptions,
55
type BatchRequestsOptions,
6-
} from '../functions/batchRequests.js'
7-
import { RequestExtendedOptions } from '../functions/request.js'
8-
import { request } from '../functions/request.js'
9-
import type { GraphQLResponse, RequestMiddleware, ResponseMiddleware } from '../helpers/types.js'
10-
import { RawRequestOptions, RequestDocument, RequestOptions, Variables } from '../helpers/types.js'
11-
export { GraphQLClient } from '../classes/GraphQLClient.js'
12-
export { batchRequests } from '../functions/batchRequests.js'
13-
export { gql } from '../functions/gql.js'
14-
export { rawRequest } from '../functions/rawRequest.js'
15-
export { analyzeDocument } from '../helpers/analyzeDocument.js'
16-
export { GraphQLWebSocketClient } from '../lib/graphql-ws.js'
6+
} from '../legacy/functions/batchRequests.js'
7+
import { RequestExtendedOptions } from '../legacy/functions/request.js'
8+
import { request } from '../legacy/functions/request.js'
9+
import type { GraphQLResponse, RequestMiddleware, ResponseMiddleware } from '../legacy/helpers/types.js'
10+
import { RawRequestOptions, RequestDocument, RequestOptions, Variables } from '../legacy/helpers/types.js'
11+
export { GraphQLClient } from '../legacy/classes/GraphQLClient.js'
12+
export { batchRequests } from '../legacy/functions/batchRequests.js'
13+
export { gql } from '../legacy/functions/gql.js'
14+
export { rawRequest } from '../legacy/functions/rawRequest.js'
15+
export { analyzeDocument } from '../legacy/helpers/analyzeDocument.js'
16+
export { GraphQLWebSocketClient } from '../legacy/lib/graphql-ws.js'
1717
export {
1818
BatchRequestDocument,
1919
BatchRequestsExtendedOptions,
File renamed without changes.

src/classes/GraphQLClient.ts renamed to src/legacy/classes/GraphQLClient.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { callOrIdentity, HeadersInitToPlainObject } from '../../lib/prelude.js'
12
import type { BatchRequestDocument, BatchRequestsOptions, BatchResult } from '../functions/batchRequests.js'
23
import { parseBatchRequestArgs } from '../functions/batchRequests.js'
34
import { parseRawRequestArgs } from '../functions/rawRequest.js'
@@ -11,7 +12,6 @@ import {
1112
type RequestConfig,
1213
type Variables,
1314
} from '../helpers/types.js'
14-
import { callOrIdentity, HeadersInitToPlainObject } from '../lib/prelude.js'
1515
import type { TypedDocumentNode } from '@graphql-typed-document-node/core'
1616

1717
/**
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/helpers/analyzeDocument.ts renamed to src/legacy/helpers/analyzeDocument.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { tryCatch } from '../../lib/prelude.js'
12
import { isOperationDefinitionNode } from '../lib/graphql.js'
2-
import { tryCatch } from '../lib/prelude.js'
33
import type { RequestDocument } from './types.js'
44
/**
55
* Refactored imports from `graphql` to be more specific, this helps import only the required files (100KiB)

src/helpers/runRequest.ts renamed to src/legacy/helpers/runRequest.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { ACCEPT_HEADER, CONTENT_TYPE_GQL, CONTENT_TYPE_HEADER, CONTENT_TYPE_JSON } from '../../lib/http.js'
2+
import { casesExhausted, uppercase, zip } from '../../lib/prelude.js'
13
import { ClientError } from '../classes/ClientError.js'
24
import type { GraphQLExecutionResultSingle } from '../lib/graphql.js'
35
import {
@@ -6,8 +8,6 @@ import {
68
isRequestResultHaveErrors,
79
parseGraphQLExecutionResult,
810
} from '../lib/graphql.js'
9-
import { ACCEPT_HEADER, CONTENT_TYPE_GQL, CONTENT_TYPE_HEADER, CONTENT_TYPE_JSON } from '../lib/http.js'
10-
import { casesExhausted, uppercase, zip } from '../lib/prelude.js'
1111
import { defaultJsonSerializer } from './defaultJsonSerializer.js'
1212
import type {
1313
BatchVariables,

src/helpers/types.ts renamed to src/legacy/helpers/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import type { MaybeLazy, RemoveIndex } from '../../lib/prelude.js'
12
import type { ClientError } from '../classes/ClientError.js'
2-
import type { MaybeLazy, RemoveIndex } from '../lib/prelude.js'
33
import type { TypedDocumentNode } from '@graphql-typed-document-node/core'
44
import type { GraphQLError } from 'graphql/error/GraphQLError.js'
55
import type { DocumentNode } from 'graphql/language/ast.js'
File renamed without changes.

src/lib/graphql.ts renamed to src/legacy/lib/graphql.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { CONTENT_TYPE_GQL, CONTENT_TYPE_JSON } from './http.js'
2-
import { isPlainObject } from './prelude.js'
1+
import { CONTENT_TYPE_GQL, CONTENT_TYPE_JSON } from '../../lib/http.js'
2+
import { isPlainObject } from '../../lib/prelude.js'
33
import { Kind } from 'graphql'
44
/**
55
* Refactored imports from `graphql` to be more specific, this helps import only the required files (100KiB)

tests/httpMethod.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { gql, GraphQLClient } from '../src/entrypoints/main.js'
2-
import type { RequestConfig } from '../src/helpers/types.js'
2+
import type { RequestConfig } from '../src/legacy/helpers/types.js'
33
import { CONTENT_TYPE_HEADER, statusCodes } from '../src/lib/http.js'
44
import { expect, test, vitest } from 'vitest'
55

tests/json-serializer.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { GraphQLClient } from '../src/entrypoints/main.js'
2-
import type { Fetch, Variables } from '../src/helpers/types.js'
2+
import type { Fetch, Variables } from '../src/legacy/helpers/types.js'
33
import { CONTENT_TYPE_HEADER, statusCodes } from '../src/lib/http.js'
44
import { setupMockServer } from './__helpers.js'
55
import { beforeEach, describe, expect, test, vitest } from 'vitest'

0 commit comments

Comments
 (0)