Skip to content

support extracted fragments in GraphiQL #14371

Description

@pieh

Summary

This should auto-attach extracted fragments to queries in graphiql:

  • in gatsby - we should push query from graphiql editor through relay-compiler to automatically attach fragments
  • in codemirror-graphql (set of graphql related extensions to codemirror editor that is used in graphiql) should transform query and attach fragments, so hints (autocomplete) and lint (red underline on unknown identifiers) make use of gatsby fragments - I opened issue in codemirror-graphql that would add support for this - https://github.com/graphql/codemirror-graphql/issues/260 , which would be nicest way forward, but if this won't be accepted we can fork it to add this feature
  • (nice to have, but not necessary) adjust graphql-language-service-interface to show fragment spread earlier so they can be discovered much easier ( https://github.com/graphql/graphql-language-service/issues/358 )

Basic example

I've made proof of concept that involved lot of monkey patching with very nice result:
Screenshot 2019-05-25 at 18 48 05
(see code changes master...pieh:graphiql-explorer-fragments )
This would need to be cleaned up, ideally changes applied in upstream packages if possible, to reduce hackiness needed to implement this in Gatsby GraphiQL editor

Motivation

This is common pain point, that queries that work in page/static queries that use fragments don't work in graphiql. Goal here is to widen support for fragments and lower friction.

Metadata

Metadata

Assignees

Labels

topic: GraphQLRelated to Gatsby's GraphQL layer

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions