Skip to content

Conversation

@PaulieScanlon
Copy link
Contributor

@PaulieScanlon PaulieScanlon commented Jul 12, 2022

Description

Amend Code Exporter Page Query GraphQL query in gatsby-graphiql-explorer

  • Rename Component to Page from ComponentName for Page Query only
  • Add condition to only replace query if it has no name.

The following query in GraphiQL...

query MyQuery($id: String) {
  sitePage(id: {eq: $id}) {
    path
  }
}

Should export as...

export const query = graphql`
  query MyQuery($id: String) {
    sitePage(id: {eq: $id}) {
      path
    }
  }
`

Not like this.

export const query = graphql`
  {
    sitePage(id: {eq: $id}) {
      path
    }
  }
`

Here's an example of the full Page Query with this change.

import React from "react"
import { graphql } from "gatsby"

const Page = ({ data }) => <pre>{JSON.stringify(data, null, 4)}</pre>

export const query = graphql`
  query MyQuery($id: String) {
    sitePage(id: {eq: $id}) {
      path
    }
  }
`

export default Page

@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jul 12, 2022
@imjoshin imjoshin added topic: GraphQL Related to Gatsby's GraphQL layer topic: DX Developer Experience (e.g. Fast Refresh, i18n, SSR, page creation, starters) and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Jul 12, 2022
@LekoArts LekoArts changed the title feat/gatsby-graphiql-explorer feat(gatsby-graphiql-explorer): Amend Query name if available Jul 13, 2022
@LekoArts LekoArts merged commit 41f88f1 into gatsbyjs:master Jul 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic: DX Developer Experience (e.g. Fast Refresh, i18n, SSR, page creation, starters) topic: GraphQL Related to Gatsby's GraphQL layer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants