apollographql / apollo-utils

Monorepo of common utilities related to Apollo and GraphQL
MIT License
36 stars 9 forks source link

Tighter integration with persisted queries and GraphQL Codegen #414

Closed jerelmiller closed 6 months ago

jerelmiller commented 6 months ago

GraphQL Codegen provides a persisted documents feature that outputs a manifest file with queries detected by the package. Unfortunately the output format and generated queries aren't fully compatible with @apollo/generate-persisted-query-manifest.

This PR aims to add tighter integration with the persisted documents feature to allow us to parse and use the documents in that manifest as the source of truth. Doing so will skip file system traversal and instead rely on the documents written to that manifest.

NOTE: It's important that we send these documents through this utility to allow Apollo Client to run any additional transforms built into the library to run on the output. Without doing so, there is a risk of query mismatch between what is written to the persisted documents manifest and what Apollo Client sends to the server. This also ensures the pq manifest file is written in the proper format.

// persisted-query-manifest.config.ts
import { fromGraphQLCodegenPersistedDocuments } from '@apollo/generate-persisted-query-manifest';

const config = {
  documents: fromGraphQLCodegenPersistedDocuments('./path/to/persisted-documents.json')
}
changeset-bot[bot] commented 6 months ago

🦋 Changeset detected

Latest commit: 3ef87a52f149fde3d32d306e4aee83e0b463016e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ----------------------------------------- | ----- | | @apollo/generate-persisted-query-manifest | Minor |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

codesandbox-ci[bot] commented 6 months ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.