Skip to content

Commit

Permalink
docs: add TSDoc to Client.prototype.graphqlFetch
Browse files Browse the repository at this point in the history
  • Loading branch information
angeloashmore committed Jan 6, 2022
1 parent ff3df7e commit a883f7e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,32 @@ export class Client {
};
}

/**
* A `fetch()` function to be used with GraphQL clients configured for
* Prismic's GraphQL API. It automatically applies the necessary `prismic-ref`
* and Authorization headers.
*
* @example
*
* ```ts
* const graphqlClient = new ApolloClient({
* link: new HttpLink({
* uri: prismic.getGraphQLEndpoint(repositoryName),
* // Provide `client.graphqlFetch` as the fetch implementation.
* fetch: client.graphqlFetch,
* // Using GET is required.
* useGETForQueries: true,
* }),
* cache: new InMemoryCache(),
* });
* ```
*
* @param input - The `fetch()` `input` parameter. Only strings are supported.
* @param init - The `fetch()` `init` parameter. Only plain objects are supported.
*
* @returns The `fetch()` Response for the request.
* @experimental
*/
async graphqlFetch(
input: RequestInfo,
init?: RequestInit,
Expand Down

0 comments on commit a883f7e

Please sign in to comment.