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

Generate page code from graphiql #14476

Open
KyleAMathews opened this issue May 31, 2019 · 1 comment

Comments

3 participants
@KyleAMathews
Copy link
Contributor

commented May 31, 2019

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.

@KyleAMathews KyleAMathews added this to To prioritize in OSS Roadmap via automation May 31, 2019

@pieh

This comment has been minimized.

Copy link
Contributor

commented Jun 1, 2019

For proof of concept - here's sample code changes pieh@14563d7
that results in:
Screenshot 2019-06-01 at 16 39 26

@m-allanson m-allanson added impact: med and removed impact: high labels Jun 3, 2019

@m-allanson m-allanson moved this from To prioritize to Prioritized in OSS Roadmap Jun 3, 2019

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