Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] GraphQL: Allow for Element query modification #5056

Open
khalwat opened this issue Oct 6, 2019 · 2 comments

Comments

@khalwat
Copy link
Contributor

commented Oct 6, 2019

One nice feature of the CraftQL plugin is that you could modify the query schemas to add your own fields to Element query schemas, for instance.

Right now I can do this with GraphQL & CraftQL:

{
  seomatic (uri: "/") {
      metaTitleContainer
      metaTagContainer
      metaLinkContainer
      metaScriptContainer
      metaJsonLdContainer
  }
}

However, I can only do this with CraftQL (unless I'm missing something):

{
  entry(section: homepage) {
    id
    title
    ... on Homepage {
      seomatic {
        metaTitleContainer
        metaTagContainer
        metaLinkContainer
        metaScriptContainer
        metaJsonLdContainer
      }
    }
  }
}

...which effectively lets you piggyback on an entries query, to return all of your data for an entry as well as the SEOmatic metadata in one request. It has access to the parent, and so can grab the uri automatically.

In order for this to be possible in the native GraphQL, you'd probably need to throw some events from ElementType::generateTypes()

https://nystudio107.com/docs/seomatic/Advanced.html#headless-spa-api

@andris-sevcenko

This comment has been minimized.

Copy link
Member

commented Oct 7, 2019

Working on this at the moment.

@andris-sevcenko

This comment has been minimized.

Copy link
Member

commented Oct 8, 2019

This is addressed in a5dd6f2 and will be a part of Craft 3.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.