gatsby-source-github icon indicating copy to clipboard operation
gatsby-source-github copied to clipboard

This query doesn't work for some reason

Open localredhead opened this issue 7 years ago • 2 comments
trafficstars

Hello,

I've been trying to determine why this query won't work with the plugin:

{

  nodes(ids: ["MDEwOlJlcG9zaXRvcnk4MDU1NzkxOQ==", "MDEwOlJlcG9zaXRvcnk3ODEzNzA3Nw==", "MDEwOlJlcG9zaXRvcnk3MjUxMjY0NA=="]) {
    id
    ... on Repository {
      url
      name
      releases(first: 2) {
        edges {
          node {
            name
            description
            url
            tag {
              name
            }
          }
        }
      }
    }
  }
}

The above query works using the github graphql explorer.. but returns an error while building, like this:


  Error: Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but "0___id" does not.
  
  - Array.map
  
  - create-sort-field.js:22 createSortField
    [docs-site]/[gatsby]/dist/schema/create-sort-field.js:22:20
  
  - build-node-connections.js:63 
    [docs-site]/[gatsby]/dist/schema/build-node-connections.js:63:16
  
  - lodash.js:516 arrayEach
    [docs-site]/[lodash]/lodash.js:516:11
  
  - lodash.js:9342 Function.forEach
    [docs-site]/[lodash]/lodash.js:9342:14
  
  - build-node-connections.js:33 module.exports
    [docs-site]/[gatsby]/dist/schema/build-node-connections.js:33:5
  
  - index.js:42 _callee$
    [docs-site]/[gatsby]/dist/schema/index.js:42:25

I did some console logging in create-sort-field.js/build-node-connections.js and noticed the following:

GithubNodesConnection
{ '0___id': { value: '0___id' },
  '1___id': { value: '1___id' },
  id: { value: 'id' },
  parent: { value: 'parent' },
  internal___type: { value: 'internal___type' },
  internal___contentDigest: { value: 'internal___contentDigest' },
  internal___content: { value: 'internal___content' },
  internal___owner: { value: 'internal___owner' } }

I was not able to intervene and remedy the error, it may be a bit beyond my knowledge of the GraphQL api.

When I changed my query to 3 separate node queries instead of a single nodes query, the console logging of the object above looks normal:

GithubNodeConnection
{ id: { value: 'id' },
  url: { value: 'url' },
  name: { value: 'name' },
  releases___edges: { value: 'releases___edges' },
  parent: { value: 'parent' },
  internal___type: { value: 'internal___type' },
  internal___contentDigest: { value: 'internal___contentDigest' },
  internal___content: { value: 'internal___content' },
  internal___owner: { value: 'internal___owner' } }

I'm hoping you may know what this issue is. Sorry in advance for any confusion on my end.

localredhead avatar Aug 07 '18 01:08 localredhead

Hi Levi!

Never apologize, it's definitely kinda confusing! Let me take a look at this and see if I can resolve it. I do know off-hand that basically the GraphQL query--as authored in Github explorer--will not work directly as is. There are fragments (...on Repository) that won't work like you'd expect with Gatsby, because we basically consume the Github GraphQL API and slightly augment its behavior.

I'll reply in a bit with more info!

DSchau avatar Aug 07 '18 15:08 DSchau

Would you be able to link to your repo, or create a reproduction repo? It'll help me debug this a lot more easily!

DSchau avatar Aug 07 '18 15:08 DSchau