Skip to content

Github GraphQL in NodeJS App: A query attribute must be specified and must be a string. #24814

Discussion options

You must be logged in to vote

The issue was short hand object notation. 

JSON.stringify({query})

is shorthand for 

JSON.stringify({query: query})

which becomes

{
query:
 {
      repository(
        owner: "PrivateOrg"
        name: "privateRepoName"
      ) {
        name
        forkCount
        forks(
          first: 11
          orderBy: { field: NAME, direction: DESC }
        ) {
          totalCount
          nodes {
            name
          }
        }
      }
    }
   }`

JSON.stringify({querytwo}) is shorthand for JSON.stringify({querytwo: querytwo}), or in other words it creates this query:

{
querytwo:
 {
      repository(
        owner: "PrivateOrg"
        name: "privateRepoName"
      ) {
        na…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants