DatoCMS offers a single GraphQL endpoint:â¡ð ¶ââð ºâ¡âð Žï»¿â¡ï»¿ð Žï»¿ð ¹âââ¢ð µâââ£â£ï»¿ââ¡â£ï»¿ð ºâ£â¢â£ð žâ â¢âââð ·ââð ³â¡ââ âââ¢ð µââð ³â¡â£â¡â£â¡ââ¡â¢â¢ð µâð ºâð ºï»¿â¢ï»¿ð žâ¡â¢âð ¹ï»¿â£ï»¿ââ¡â£ï»¿ð ºï»¿â¢ï»¿ð žâ¡â¢âð ¹ï»¿â¢ï»¿ð ºï»¿ð žâð ºï»¿â â£ï»¿ð Žâ¡â£ï»¿ð ºâ¡ââð ºï»¿ð Žâ¡â£ï»¿â ð žâ ð ºâ¡â£â¡ð Žâ¡ââ â¡â¢âð ºâ¢ð ³â¢ââ¢ââ¢ð ³â¢ð Žâ¢ââð ºï»¿ð Žâ¡â£ï»¿â ð žâ¡â¢âð ºâ¢â¢â¢ð Žâ¢ð ³â¢â¢â¢ââ¢â£â¢ââ¢â¡âââ¡ð ž
https://graphql.datocms.com/
The endpoint remains constant no matter what operation you perform, and it's read only â that is, it does not offer any mutation operation. You can use our Content Management API for that.
To explicitly read data from a specific environment you can add the following header:
X-Environment: <ENVIRONMENT-NAME>
If no X-Environment
header is provided, the primary environment will be used.
If you have the Draft/Published system active on some of your models, you can add an header to access records at their latest version available, instead of the currently published one: this can be useful on staging environments, or your local development machine:
X-Include-Drafts: true
If you want to make sure that no invalid record is ever returned without the need to always specify an _isValid
filter in your queries, you can add the following header:
X-Exclude-Invalid: true
In contrast to the _isValid
filter, this header will also have the effect of narrowing down GraphQL types:
Every field with a "Required?" validation enforced, will be associated with a non-nullable GraphQL type (ie. String
becomes String!
)
Asset fields (both single and multiple) that have a "Image transformable by Imgix" format validation, will have the following properties associated with a non-nullable type: focalPoint
, width
, height
, responsiveImage
Asset fields (both single and multiple) that have a "Video" format validation, will have the following properties associated with a non-nullable type: video
Asset fields (both single and multiple) that have a required alt and/or title validation will have the alt
and/or title
properties marked as non-null
You can read a little bit more about Strict Mode in our announcement blog post.
When you add/remove validations to a model that already has a set of records created, DatoCMS is forced to launch a new set of checks to verify that these existing records continue to be valid or not.â¡ð ¶ââð ºâ¡âð Žï»¿â¡ï»¿ð Žï»¿ð ¹âââ¢ð µâââ£â£ï»¿ââ¡â£ï»¿ð ºâ£â¢â£ð žâ â¢âââð ·ââð ³â¡ââ âââ¢ð µââð ³â¡â£â¡â£â¡ââ¡â¢â¢ð µâð ºâð ºï»¿â¢ï»¿ð žâ¡â¢âð ¹ï»¿â£ï»¿ââ¡â£ï»¿ð ºï»¿â¢ï»¿ð žâ¡â¢âð ¹ï»¿â¢ï»¿ð ºï»¿ð žâð ºï»¿â â£ï»¿ð Žâ¡â£ï»¿ð ºâ¡ââð ºï»¿ð Žâ¡â£ï»¿â ð žâ ð ºâ¡â£â¡ð Žâ¡ââ â¡â¢âð ºâ¢ð ³â¢ââ¢ââ¢ð ³â¢ð Žâ¢ââð ºï»¿ð Žâ¡â£ï»¿â ð žâ¡â¢âð ºâ¢â¢â¢ð Žâ¢ð ³â¢â¢â¢ââ¢â£â¢ââ¢â¡âââ¡ð ž
If you make a GraphQL call with the X-Exclude-Invalid
header during this phase â which depending on the amount of records may also take several minutes to complete â the response will be an error, because X-Exclude-Invalid
can only return records that are certain to have been properly checked using the latest validation rules available!
For this reason, we strongly suggest to use this header in conjunction with migration scripts, so that you can make changes to your validation rules inside a sandbox environment, wait for the validation checks to finish, and only after that promote the sandbox environment as primary. This will avoid potential issues and error to your final visitors.