Metatag
Last updated
Was this helpful?
Last updated
Was this helpful?
The easiest way to use the Metatag module together with GraphQL is to use the module. It comes with built-in support for using metatags with GraphQL.
This will give you something like this as a response :
This way you can easily manipulate SEO information in the Node in Drupal but still be able to properly inject this in your application by fetching this information out of the node.
You can of course use this in any kind of query that would return the entity that holds the metatag information. As an example querying a route and getting from that entity the metatag information would look something like this :
This would return any information on this particular route, including the meta information requested.
"If a module (e.g. metatag) introduces a new primitive data type, it is not part of the derived types, but any field using it will reference it. That results in a "Missing type metatag." exception."
So for now you need to include a custom Scalar as a workaround to avoid errors in GraphQL due to this missing type. Create a file inside a custom module of your own, named for example "MetatagScalar.php" where a custom scalar will be defined. In this example the module's name is graphql_custom as seen from the namespace bellow. Make sure to not conflict with existing namespaces when defining it.
for more information on routes check out the . Writting custom plugins you could also mutate fields of this type. You can learn more about these in the section .
There is a currently an opened for using the metatag module together with the GraphQL module :