Configuring URL-GraphQL query mappings
The GraphQL query that is executed to retrieve content for any given
URL is determined by the
cue-front-extension-path-mapper
recipe extension.
cue-front-extension-path-mapper
does this by
applying mapping rules specified in
cook-config.yaml
.
By default, cook-config.yaml
contains the following
mapping rules:
- name: @escenic/cue-front-extension-path-mapper config: directory: "esi" criteria: match: '\.esi\/([a-zA-Z0-9-]+)' base-name: "$1" lookup: - BASE - name: @escenic/cue-front-extension-path-mapper config: directory: "." lookup: - TYPE-SECTION - TYPE
These rules basically say:
-
The response for any URL that starts with the string
.esi/
will be generated by the query calledesi/
base-name.graphql
where base-name matches the URL segment identified by$1
(in this case, the remainder of the URL – so long as it only contains alphanumeric characters and hyphens). This rule is using theBASE
lookup algorithm. -
The response for any other URL will be generated according to the rules described in Mapping URLs To GraphQL Queries, using the
TYPE-SECTION
andTYPE
lookup algorithms.
cook-config.yaml
may contain as many of these
mapping rules as you need. The rules are applied in the order they are
defined in cook-config.yaml
, and the first rule to
match a URL is used. The same applies when multiple lookup algorithms
are applied within a single rule as in the second rule above: the
first algorithm to get a match wins.
For a full description of all the available
cue-front-extension-path-mapper
lookup algorithms
and how to use them, see the
cue-front-extension-path-mapper
README file.