Skip to content

Commit

Permalink
refactor: modualarize api (#653)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt committed Jan 25, 2024
1 parent ec2354c commit 4cadba3
Show file tree
Hide file tree
Showing 46 changed files with 539 additions and 529 deletions.
2 changes: 1 addition & 1 deletion examples/community-graphql-code-generator.ts
Expand Up @@ -12,7 +12,7 @@
* @see https://www.the-guild.dev/graphql/codegen/docs/guides/react-vue.
*/

import request, { gql } from '../src/index.js'
import request, { gql } from '../src/entrypoints/main.js'
// @ts-expect-error todo make this actually work
import { graphql } from './gql/gql'

Expand Down
2 changes: 1 addition & 1 deletion examples/configuration-fetch-custom-function.ts
@@ -1,4 +1,4 @@
import { gql, GraphQLClient } from '../src/index.js'
import { gql, GraphQLClient } from '../src/entrypoints/main.js'
import fetchCookie from 'fetch-cookie'

const endpoint = `https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr`
Expand Down
2 changes: 1 addition & 1 deletion examples/configuration-fetch-options.ts
@@ -1,4 +1,4 @@
import { gql, GraphQLClient } from '../src/index.js'
import { gql, GraphQLClient } from '../src/entrypoints/main.js'

const endpoint = `https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr`

Expand Down
2 changes: 1 addition & 1 deletion examples/configuration-incremental-endpoint.ts
Expand Up @@ -2,7 +2,7 @@
* If you want to change the endpoint after the GraphQLClient has been initialized, you can use the `setEndpoint()` function.
*/

import { GraphQLClient } from '../src/index.js'
import { GraphQLClient } from '../src/entrypoints/main.js'

const client = new GraphQLClient(`https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr`)

Expand Down
2 changes: 1 addition & 1 deletion examples/configuration-incremental-request-headers.ts
Expand Up @@ -2,7 +2,7 @@
* If you want to set headers after the GraphQLClient has been initialized, you can use the `setHeader()` or `setHeaders()` functions.
*/

import { GraphQLClient } from '../src/index.js'
import { GraphQLClient } from '../src/entrypoints/main.js'

const client = new GraphQLClient(`https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr`)

Expand Down
2 changes: 1 addition & 1 deletion examples/configuration-request-json-serializer.ts
Expand Up @@ -3,7 +3,7 @@
* An original use case for this feature is `BigInt` support:
*/

import { gql, GraphQLClient } from '../src/index.js'
import { gql, GraphQLClient } from '../src/entrypoints/main.js'
import JSONbig from 'json-bigint'

const jsonSerializer = JSONbig({ useNativeBigInt: true })
Expand Down
2 changes: 1 addition & 1 deletion examples/graphql-batching-requests.ts
Expand Up @@ -2,7 +2,7 @@
* It is possible with `graphql-request` to use batching via the `batchRequests()` function.
* @see https://github.com/graphql/graphql-over-http/blob/main/rfcs/Batching.md
*/
import { batchRequests, gql } from '../src/index.js'
import { batchRequests, gql } from '../src/entrypoints/main.js'

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

Expand Down
2 changes: 1 addition & 1 deletion examples/graphql-document-variables.ts
@@ -1,4 +1,4 @@
import { gql, request } from '../src/index.js'
import { gql, request } from '../src/entrypoints/main.js'

const endpoint = `https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr`

Expand Down
2 changes: 1 addition & 1 deletion examples/graphql-mutations.ts
@@ -1,4 +1,4 @@
import { gql, GraphQLClient } from '../src/index.js'
import { gql, GraphQLClient } from '../src/entrypoints/main.js'

const endpoint = `https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr`

Expand Down
2 changes: 1 addition & 1 deletion examples/other-error-handling.ts
@@ -1,4 +1,4 @@
import { gql, request } from '../src/index.js'
import { gql, request } from '../src/entrypoints/main.js'

const endpoint = `https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr`

Expand Down
4 changes: 2 additions & 2 deletions examples/other-middleware.ts
Expand Up @@ -2,8 +2,8 @@
* It's possible to use a middleware to pre-process any request or handle raw response.
*/

import { GraphQLClient } from '../src/index.js'
import type { RequestMiddleware, ResponseMiddleware } from '../src/types.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
2 changes: 1 addition & 1 deletion examples/request-authentication-via-http-header.ts
@@ -1,4 +1,4 @@
import { gql, GraphQLClient } from '../src/index.js'
import { gql, GraphQLClient } from '../src/entrypoints/main.js'

const endpoint = `https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr`

Expand Down
2 changes: 1 addition & 1 deletion examples/request-cancellation.ts
Expand Up @@ -2,7 +2,7 @@
* It is possible to cancel a request using an `AbortController` signal.
*/

import { gql, GraphQLClient } from '../src/index.js'
import { gql, GraphQLClient } from '../src/entrypoints/main.js'

const endpoint = `https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr`

Expand Down
2 changes: 1 addition & 1 deletion examples/request-handle-raw-response.ts
Expand Up @@ -3,7 +3,7 @@
* If you need to access the `extensions` key you can use the `rawRequest` method:
*/

import { gql, rawRequest } from '../src/index.js'
import { gql, rawRequest } from '../src/entrypoints/main.js'

const endpoint = `https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr`

Expand Down
2 changes: 1 addition & 1 deletion examples/request-headers-dynamic-per-request.ts
Expand Up @@ -3,7 +3,7 @@
* To do that, pass a function that returns the headers to the `headers` property when creating a new `GraphQLClient`.
*/

import { gql, GraphQLClient } from '../src/index.js'
import { gql, GraphQLClient } from '../src/entrypoints/main.js'

const client = new GraphQLClient(`https://some-api`, {
headers: () => ({ 'X-Sent-At-Time': Date.now().toString() }),
Expand Down
2 changes: 1 addition & 1 deletion examples/request-headers-static-per-request.ts
Expand Up @@ -2,7 +2,7 @@
* It is possible to pass custom headers for each request. `request()` and `rawRequest()` accept a header object as the third parameter
*/

import { gql, GraphQLClient } from '../src/index.js'
import { gql, GraphQLClient } from '../src/entrypoints/main.js'

const endpoint = `https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr`

Expand Down
2 changes: 1 addition & 1 deletion examples/request-method-get.ts
@@ -1,7 +1,7 @@
/**
* Queries can be sent as an HTTP GET request:
*/
import { gql, GraphQLClient } from '../src/index.js'
import { gql, GraphQLClient } from '../src/entrypoints/main.js'

const endpoint = `https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr`

Expand Down
2 changes: 1 addition & 1 deletion examples/typescript-typed-document-node.ts
@@ -1,4 +1,4 @@
import { gql, GraphQLClient, request } from '../src/index.js'
import { gql, GraphQLClient, request } from '../src/entrypoints/main.js'
import type { TypedDocumentNode } from '@graphql-typed-document-node/core'
import { parse } from 'graphql'

Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -5,8 +5,8 @@
"exports": {
".": {
"import": {
"types": "./build/index.d.ts",
"default": "./build/index.js"
"types": "./build/entrypoints/main.d.ts",
"default": "./build/entrypoints/main.js"
}
}
},
Expand Down

0 comments on commit 4cadba3

Please sign in to comment.