Tags
Caisy automatically generates queries for fetching your documents for each defined blueprint of your project. Depending, if your blueprint is defined as unique, you will have a query to fetch multiple entries.
When a new blueprint is added to your project, there are one or more generated GraphQL queries added to your schema. Responsible for the name is the field API ID
of the blueprint.
Lets you want to define a blueprint called MainNavigation
. That is something that should only exist once. So you define it as a unique blueprint. The result will be that the External API will generate only this single query for you.
MainNavigation
The MainNavigation
query is what you would use now to fetch the single document that can exist from the External API.
If the blueprint is marked as unique you do not need to provide the id
in the query.
{ MainNavigation { id title }}
Plural queries come with their own generated arguments for filtering, ordering, paginated.
For example, let’s assume we have the model Page
in our blueprint, and not make it unique. The following queries would be generated in the External API automatically:
Page
allPage
Now we can use the allPage
query to retrieve multiple documents from the External API.
{
allPage{
edges{
node{
id
slug
title
}
}
}
}
Imagine we would connect our pages to the main navigation. To do so, you would need to update the MainNavigation
blueprint with a connection field that is connecting the Page
blueprint. Afterwards, if we want to query the MainNavigation
together with the links to the Page
, we could use the following query:
{
MainNavigation{
title
id
links{
... on Page {
slug
id
title
}
}
}
}
Subscribe to our newsletters
and stay updated
While you subscribe you agree to our Privacy Policy and Terms of Service apply.
Tags