Skip to content

Commit 1ef0906

Browse files
piehsidharthachatterjee
authored andcommitted
blog: update graphiql improevements blog post with code exporter section (#17732)
1 parent b08327f commit 1ef0906

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed
Binary file not shown.

docs/blog/2019-06-03-integrating-graphiql-explorer/index.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ tags:
88
- developer-experience
99
---
1010

11+
[_Updated September 19th 2019_](#update-september-19th-2019)
12+
1113
Gatsby's data layer is powered by [GraphQL](https://graphql.org/). This means that if you are building a Gatsby site, you will almost certainly use GraphQL to take advantage of Gatsby's rich plugin ecosystem that extends this schema with data from _anywhere_. A popular tool for exploring your GraphQL schema is [GraphiQL](https://github.com/graphql/graphiql) — which is a graphical, interactive, in-browser GraphQL development environment. It serves as an interactive playground where you can compose, test, and see the live results of your queries. If you haven't seen or used GraphiQL, it looks something like this:
1214

1315
<figure>
@@ -74,4 +76,35 @@ There are opportunities for further improvements for Gatsby users. Few things we
7476

7577
- evaluating accessibility of GraphiQL interface and addressing found issues,
7678
- adding [support for using GraphQL fragments provided by Gatsby plugins](https://github.com/gatsbyjs/gatsby/issues/14371),
77-
- adding [code snippet generation for common workflows](https://github.com/gatsbyjs/gatsby/issues/14476) (using another awesome OneGraph's GraphiQL addon - [`graphiql-code-exporter`](https://github.com/OneGraph/graphiql-code-exporter)).
79+
- ~~adding [code snippet generation for common workflows](https://github.com/gatsbyjs/gatsby/issues/14476) (using another awesome OneGraph's GraphiQL addon - [`graphiql-code-exporter`](https://github.com/OneGraph/graphiql-code-exporter)).~~ [Check update!](#update-september-19th-2019)
80+
81+
## Update (September 19th 2019)
82+
83+
Code snippet generation (mentioned in [Future work section](#future-work)) was added in `[email protected]`! Huge thanks to [Dan Kirkham](https://twitter.com/herecydev) who integrated `graphiql-code-exporter` into Gatsby's GraphiQL IDE!
84+
85+
Snippets we currently support are:
86+
87+
- Page templates
88+
- Components using static queries (both `<StaticQuery>` and `useStaticQuery` variants)
89+
90+
Using those snippets allows users to quickly scaffold new pages and components that use queries created in GraphiQL IDE.
91+
92+
Usual flow would look like this:
93+
94+
1. compose your query in GraphiQL,
95+
2. click "Code Exporter" button in GraphiQL's toolbar,
96+
3. select type of snippet
97+
4. click "copy" button (or manually select generated code snippet and copy it),
98+
5. paste copied snippet into new file in your code editor and save it.
99+
100+
Now you have working page or component that uses your query!
101+
102+
<figure>
103+
<video controls="controls" autoplay="false">
104+
<source type="video/mp4" src="./graphiql-exporter-demo.mp4" />
105+
<p>Your browser does not support the video element.</p>
106+
</video>
107+
<figcaption>Demo of scaffolding new page with GraphiQL Code Exporter</figcaption>
108+
</figure>
109+
110+
Interested in checking how Dan did this? Check his [Pull request](https://github.com/gatsbyjs/gatsby/pull/17120)!

0 commit comments

Comments
 (0)