An idea from @sgrove / @pieh
OneGraph generates code for you from GraphQL queries — we could do the same thing for Gatsby as a very common workflow is going to GraphiQL to sketch out the query for a page and then using that query for the new page. We could add a button that generates code like the following:
import React from "react"
import { graphql } from "gatsby"
export default ({ data }) => <pre>{JSON.stringify(data, null, 4)}</pre>
export const query graphql`
INSERT GRAPHQL QUERY HERE
`
Initially we could just give them code to copy paste. There's been conversations about adding an API to Gatsby so we can write out to the file from tooling in the browser so eventually we might be able to just ask them what path they want the new page at and we'd directly create the file there and give them a link to open.
For proof of concept - here's sample code changes https://github.com/pieh/gatsby/commit/14563d722f9ab86c647b34e45c2ca476dc2bc737
that results in:

Definitely want to keep a eye on this one!
On Tue, Jun 25, 2019 at 10:28 AM gatsbot[bot] notifications@github.com
wrote:
Hiya!
This issue has gone quiet. Spooky quiet. 👻
We get a lot of issues, so we currently close issues after 30 days of
inactivity. It’s been at least 20 days since the last update here.If we missed this issue or if you want to keep it open, please reply here.
You can also add the label "not stale" to keep this issue open!As a friendly reminder: the best way to see this issue, or any other,
fixed is to open a Pull Request. Check out gatsby.dev/contribute
https://www.gatsbyjs.org/contributing/how-to-contribute/for more
information about opening PRs, triaging issues, and contributing!Thanks for being a part of the Gatsby community! 💪💜
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/gatsbyjs/gatsby/issues/14476?email_source=notifications&email_token=AAAITYBLS7PBBOYMSMMVAVDP4JITDA5CNFSM4HR6GFAKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYQ7S2Q#issuecomment-505543018,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAITYGIHFWQP6EFH74QNQTP4JITDANCNFSM4HR6GFAA
.
I'm going to give this a try if you don't mind?
Most helpful comment
For proof of concept - here's sample code changes https://github.com/pieh/gatsby/commit/14563d722f9ab86c647b34e45c2ca476dc2bc737

that results in: