-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Plugin: Gatsby-style implicit fragments #612
Comments
Yes, this would be really great to get, as not having the fragment schemas in the outputted schema file at: http://localhost:8000/___graphql? breaks other things like compiling GraphQL types for things like typescript using apollo-codegen - as they validate the schema, and it's invalid without these fragments :-( |
@KyleAMathews Apollo server has an updated graphiQL now, I think its the one from graphcool and prisma. Maybe it solve the issue ? |
@ScreamZ I just tried generating types with the most recent apollo-cli ([email protected]), but it still throws "Unknown fragment "GatsbyImageSharpFixed"" :( |
I just ran into the same thing while building an emit-types plugin around relay-compiler-language-typescript. If I omit the plugin fragment things work great: example % yarn relay
yarn run v1.13.0
$ relay-compiler --src . --schema schema.graphql --language typescript --artifactDirectory ./src/__generated__
HINT: pass --watch to keep watching for changes.
Writing ts
Created:
- seoQuery.graphql.ts
- BioQuery.graphql.ts However, when including the fragment the compiler throws an error: ERROR:
GraphQLCompilerContext: Unknown document `GatsbyImageSharpFixed`. |
@kkor sounds like a different but similar issue |
I created a plugin which one can use to easily demo the issue: https://github.com/damassi/gatsby-plugin-emit-graphql-types. |
This is a known issue, but it could confuse new Gatsby users (like myself). [See the `gatsby-image` docs for details](https://www.gatsbyjs.org/packages/gatsby-image/#fragments), and [this GraphiQL issue for progress on a fix](graphql/graphiql#612).
…QL (#25387) * Add a note about queries not working in GraphiQL This is a known issue, but it could confuse new Gatsby users (like myself). [See the `gatsby-image` docs for details](https://www.gatsbyjs.org/packages/gatsby-image/#fragments), and [this GraphiQL issue for progress on a fix](graphql/graphiql#612). * chore: format * Update docs/tutorial/gatsby-image-tutorial/index.md Co-authored-by: Yogi <[email protected]> * Fix relative link Co-authored-by: gatsbybot <[email protected]> Co-authored-by: Ward Peeters <[email protected]> Co-authored-by: Yogi <[email protected]> Co-authored-by: Aisha Blake <[email protected]>
…gatsby-image` fragments not working in GraphiQL (#25387) * Add a note about queries not working in GraphiQL This is a known issue, but it could confuse new Gatsby users (like myself). [See the `gatsby-image` docs for details](https://www.gatsbyjs.org/packages/gatsby-image/#fragments), and [this GraphiQL issue for progress on a fix](graphql/graphiql#612). * chore: format * Update docs/tutorial/gatsby-image-tutorial/index.md Co-authored-by: Yogi <[email protected]> * Fix relative link Co-authored-by: gatsbybot <[email protected]> Co-authored-by: Ward Peeters <[email protected]> Co-authored-by: Yogi <[email protected]> Co-authored-by: Aisha Blake <[email protected]>
…QL (#25387) * Add a note about queries not working in GraphiQL This is a known issue, but it could confuse new Gatsby users (like myself). [See the `gatsby-image` docs for details](https://www.gatsbyjs.org/packages/gatsby-image/#fragments), and [this GraphiQL issue for progress on a fix](graphql/graphiql#612). * chore: format * Update docs/tutorial/gatsby-image-tutorial/index.md Co-authored-by: Yogi <[email protected]> * Fix relative link Co-authored-by: gatsbybot <[email protected]> Co-authored-by: Ward Peeters <[email protected]> Co-authored-by: Yogi <[email protected]> Co-authored-by: Aisha Blake <[email protected]>
…QL (#25387) * Add a note about queries not working in GraphiQL This is a known issue, but it could confuse new Gatsby users (like myself). [See the `gatsby-image` docs for details](https://www.gatsbyjs.org/packages/gatsby-image/#fragments), and [this GraphiQL issue for progress on a fix](graphql/graphiql#612). * chore: format * Update docs/tutorial/gatsby-image-tutorial/index.md Co-authored-by: Yogi <[email protected]> * Fix relative link Co-authored-by: gatsbybot <[email protected]> Co-authored-by: Ward Peeters <[email protected]> Co-authored-by: Yogi <[email protected]> Co-authored-by: Aisha Blake <[email protected]>
…QL (#25387) * Add a note about queries not working in GraphiQL This is a known issue, but it could confuse new Gatsby users (like myself). [See the `gatsby-image` docs for details](https://www.gatsbyjs.org/packages/gatsby-image/#fragments), and [this GraphiQL issue for progress on a fix](graphql/graphiql#612). * chore: format * Update docs/tutorial/gatsby-image-tutorial/index.md Co-authored-by: Yogi <[email protected]> * Fix relative link Co-authored-by: gatsbybot <[email protected]> Co-authored-by: Ward Peeters <[email protected]> Co-authored-by: Yogi <[email protected]> Co-authored-by: Aisha Blake <[email protected]>
…QL (#25387) * Add a note about queries not working in GraphiQL This is a known issue, but it could confuse new Gatsby users (like myself). [See the `gatsby-image` docs for details](https://www.gatsbyjs.org/packages/gatsby-image/#fragments), and [this GraphiQL issue for progress on a fix](graphql/graphiql#612). * chore: format * Update docs/tutorial/gatsby-image-tutorial/index.md Co-authored-by: Yogi <[email protected]> * Fix relative link Co-authored-by: gatsbybot <[email protected]> Co-authored-by: Ward Peeters <[email protected]> Co-authored-by: Yogi <[email protected]> Co-authored-by: Aisha Blake <[email protected]>
good news! so we have this fully working in the LSP and on the server side, for both validation and completion. you can use vscode-graphql as an example implementation of the lsp server. a vim coc plugin for relay will soon offer this as well works great with gatsby’s plugin fragments, for example. now i can introduce this to codemirror graphql and monaco graphql, and also to graphiql. also works for definition lookips. the gls interface autocomplete method now accepts an array of i’m thinking that GraphiQL could accept a prop called fragments that would just be a string of all the fragments. if this prop gets updated, the lsp interface would take up the new fragments for validation, completion. eventually with monaco-graphql in 2.x we will have peek definitions like we have in vscode-graphql now! |
here's what was introduced specifically: graphiql/packages/graphql-language-service-interface/src/getAutocompleteSuggestions.ts Line 73 in 39f5e45
this allows autocompletion support for externally provided fragments! we use it to allow autocompletion in the IDE extensions here's what needs to happen next to make this work in GraphiQL 1:
here's whats needed for monaco editor:
|
allows external, implied fragments in autocompletion, validation, and operation execution
allows external, implied fragments in autocompletion, validation, and operation execution. resolves #612 - adds this capability to `monaco-graphql`, `codemirror-graphql`, and `graphiql`. it was already present in `graphql-language-service-interface`. - provide an array of fragment definitions or a string containing fragment definitions - only fragments you use are added in operation exec, thus in fetcher params as well - still only shows valid autocomplete entries for fragment spread - also exposes a documentAST of the current operation in `onEditQuery` and in the `fetcher`
…QL (#25387) * Add a note about queries not working in GraphiQL This is a known issue, but it could confuse new Gatsby users (like myself). [See the `gatsby-image` docs for details](https://www.gatsbyjs.org/packages/gatsby-image/#fragments), and [this GraphiQL issue for progress on a fix](graphql/graphiql#612). * chore: format * Update docs/tutorial/gatsby-image-tutorial/index.md Co-authored-by: Yogi <[email protected]> * Fix relative link Co-authored-by: gatsbybot <[email protected]> Co-authored-by: Ward Peeters <[email protected]> Co-authored-by: Yogi <[email protected]> Co-authored-by: Aisha Blake <[email protected]>
I'm adding support to Gatsby for components/plugins to ship with fragments that can be used out-of-the-box when building sites.
It'd be great if there was a way to add these to GraphiQL. Right now there's no way to add a fragment other than changing the default text and that still wouldn't work as then graphiql would fail as there'd be unused fragments.
If it's possible to add fragments to the schema and I just missed that, would love a pointer there!
The text was updated successfully, but these errors were encountered: