close

Filter

loading table of contents...

Headless Server Developer Manual / Version 2310

Table Of Contents

9.1.3 Defining Persisted Query Maps in Relay Format

The Relay Compiler may be asked to extract GraphQL queries from your client code and to generate a JSON file containing a map from query IDs (which are MD5 hashes) to query strings, for example:

{
  "33c07385fca167d81c2906b4f2ada3ac": "query AppArticleQuery(....) {...}}",
  "d614bb0396056705ef5a00815b828076": "query AppPageQuery(....) {...}}",
  ...
}

This map can then be used by your client and the Headless Server for query whitelisting (see next section).

For the Headless Server, the JSON map must be accessible at server startup time as a resource resolvable by a Spring PathMatchingResourcePatternResolver. One way to do this is to transfer the JSON file to the Headless Server workspace for inclusion at build time as a Java resource file. By default, for the Headless Server, the JSON map must be transferred to the Headless Server workspace to be included at build time. The Headless Server looks for Apollo query maps at locations specified by the configuration property caas.persisted-queries.relay-query-map-resources-pattern, which defaults to classpath:graphql/queries/relay*.json.

Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.