-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to specify custom document transform during manifest gene…
…ration (#412) Apollo Client v3.8 added support for [custom document transforms](https://www.apollographql.com/docs/react/data/document-transforms) that can be used to modify queries before they are sent to the server. This change adds support for this feature during manifest generation to ensure the queries saved to the manifest match what will be sent by the client in a running app.
- Loading branch information
1 parent
88c8267
commit c43f485
Showing
7 changed files
with
168 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
"@apollo/generate-persisted-query-manifest": minor | ||
--- | ||
|
||
Add ability to specify a custom document transform used during manifest generation. | ||
|
||
> [!NOTE] | ||
> You must be running Apollo Client 3.8.0 or greater to use this feature. | ||
> [!IMPORTANT] | ||
> This should be the same document transform that is passed to your `ApolloClient` instance, otherwise you risk mismatches in the query output. | ||
```ts | ||
// persisted-query-manifest.config.ts | ||
import { PersistedQueryManifestConfig } from "@apollo/generate-persisted-query-manifest"; | ||
import { DocumentTransform } from "@apollo/client/core"; | ||
|
||
const documentTransform = new DocumentTransform((document) => { | ||
// transform your document | ||
return transformedDocument; | ||
}) | ||
|
||
const config: PersistedQueryManifestConfig = { | ||
documentTransform, | ||
}; | ||
|
||
export default config; | ||
``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters