Headless Server Developer Manual / Version 2406.1
Table Of Contents
All resources matching the pattern configured with the property
caas.persisted-queries.query-resources-pattern
are loaded as persisted queries, one query per resource file. The filename without extension serves as the query ID.
The pattern must be suitable for a Spring PathMatchingResourcePatternResolver
which is used to load these resources.
The default pattern is classpath:graphql/queries/*.graphql
,
which means that all resource files within the
graphql/queries
directory are loaded if they have the graphql
file extension.
Actually, not all resource files matching this pattern might be loaded - there is a configuration property
caas.persisted-queries.exclude-file-name-pattern
that specifies a regular expression
for resource files to be ignored.
This pattern defaults to .*Fragment(s)?.graphql
which is useful to
skip resource files holding reusable query fragments. These fragments may then be included into
a query file by means of the
#import
directive. The following is an example query including fragments from the resource
referenceFragments.graphql
:
query ArticleQuery($id: String!) { content { article(id: $id) { ... Reference title detailText teaserTitle teaserText } } } #import "./referenceFragments.graphql"
If this query is saved in a resource file with the name article.graphql
,
the query will have the ID
article
. Therefore, you may now send an HTTP GET request with just this ID instead of the query string (mind URL encoding):
wget -q -O - 'http://myheadlessserver:41180/graphql \ ?query=PersistedQueryMarker \ &extensions={"persistedQuery": {"version": 1,"queryId": "article"}} \ &variables={"id":"1556"}'