Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: modualarize api #653

Merged
merged 4 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/community-graphql-code-generator.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
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 { 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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Loading