How to filter for a Craft CMS site in a GraphQL Mutation

A step by step guide on filtering a GraphQL mutation for a specific Craft CMS site.

Oscar de la Hera Gomez
Written by Oscar de la Hera Gomez
First published on 02/14/2023 at 13:24
Last Updated on 02/14/2023 at 13:39
Two flowers that represent Craft CMS and GraphQL side by side. Beneath them sits the text "GraphQL Mutation Site Filter."

A step by step guide on filtering a GraphQL mutation for a specific Craft CMS site.

SubscribeDownload Open Source Craft CMS project

The following tutorial walks you through how to filter a GraphQL mutation for a specific site in a multisite Craft CMS. It assumes that you have setup Craft CMS to work with the GraphQL, and have multiple sites setup.

If you wish to learn how to do the above, please consult the tutorials below.

How to setup Craft CMS to work with the GraphQLHow to create a GraphQL schema in Craft CMSHow to split Craft CMS into multiple websites

Step One: Access the GraphiQL

A screenshot of the Craft CMS GraphiQL.

On your browser, access the Craft CMS GraphiQL by replacing YOUR_CRAFT_URL with the URL of your Craft CMS in the url below.

YOUR_CRAFT_URL/admin/graphiql

Step Two: Write the Mutation

A screenshot of a sample GraphQL mutation with a siteId parameter.

Please note that we used * in the screenshot above, which filters for all websites.

In the GraphiQL, write the mutation and add a siteId parameter with the handle of the website that you wish to filter for in that mutation. This implies that you need to identify for the Id of the website before passing it on to the mutation.

Search our blog for Craft CMS GraphQL mutation tutorials

Any Questions?

We are actively looking for feedback on how to improve this resource. Please send us a note to inquiries@delasign.com with any thoughts or feedback you may have.
SubscribeContact UsVisit our BlogView our ServicesView our Work

Partner with us

We would love to get to know you and see how we can help your organization with its goals and needs.
Let's Talk

Stay Informed

Get occasional updates about our company, research, and product launches.
Subscribe