Is There an Operation Name Bug? Or Am I Missing Something?


#1

In the GraphiQL front-end for the GraphQL API, I enter the following:

query login {
  viewer {
    login
  }
}

query starred($count: Int) {
  viewer {
    login
    starredRepositories(first: $count, orderBy: {field: STARRED_AT, direction: DESC}) {
      edges {
        node {
          name
        }
      }
    }
  }
}

When I run it, I get the standard GraphiQL drop-down to choose between the two operation names. However, no matter which I choose, I get:

{
  "data": null,
  "errors": [
    {
      "message": "You must provide an operation name from: login, starred"
    }
  ]
}

This is not unique to the GraphiQL setup, as I can get this same error when I submit my own HTTP POST request with an operationName.

Does the GraphQL API not support a GraphQL document with multiple operations? Or am I screwing this up somehow?

Thanks!


#2

When you pass multiple queries, you’re passing us a Document technically speaking. Normally, you’d specify an operationName as part of the query parameters but I’m not sure we’re handling that correctly. I’ve registered a bug on our side so we can take a look at this for you!


#3

OK, thanks!

Is this issue tracker public? If not, what’s the best way for people like me to find out if/when a change is made that addresses this?

Thanks again!


#4

There isn’t a public tracker (this forum is as close of a public tracker as we have for GraphQL). Once we fix the problem, we do come back into these threads and let folks know though. :sparkles:


#5

OK, thanks again!


#6

Sorry for the delay in this! We just rolled out the fix. :v:


#7

I’m pretty certain I’m still witnessing this same issue.

query LastReleaseDate {
  repository(owner: "xyz", name: "xyz") {
    releases(last: 1) {
      edges {
        node {
          publishedAt
          tag {
            name
          }
        }
      }
    }
  }
}

query PullsMergedSince {
  search(first: 50, type:ISSUE, query: "is:closed is:pr user:xyz merged:>=2017-06-07 NOT Release") {
    edges {
      node {
        ... on PullRequest {
          number,
          title,
          mergedAt
        }
      }
    }
  }  
}

Results in…

{
  "data": null,
  "errors": [
    {
      "message": "An operation name is required"
    }
  ]
}

#8

How is the query being run?

If more than one query is provided (as in your case – LastReleaseDate and PullsMergedSince), you absolutely must provide the operationName along with that query string.

The original issue was that we weren’t supporting operationName at all!


#9

Thanks @gjtorikian, I misread this a bit. I thought you meant we simply had to have our operations named (A la LastReleaseData and PullsMergedSince). There doesn’t appear to be anything in the docs about operationName, so I’m still not clear on what is required.


#10

Sorry for the confusion, I’ve opened up another internal issue to get the docs updated.

operationName is part of the GraphQL standard:

If you’re passing in your queries, you’d append &operationName=<operation_to_run> to select the GraphQL operation to execute. Even if a GraphQL query has multiple operations, you still need to provide the name of the operation to run.

In GraphiQL / GitHub’s GraphQL Explorer, you can select the operation name after clicking the “Run” button (a dropdown will list the operations in your query, and you select the one to run).