graphql.js
graphql.js copied to clipboard
"An operation name is required if the query contains multiple operations"
Hi. I am trying to put many queries and fragments inside one request. My POST request's body:
query login {
createSession(email:"[email protected]", password: "foobar"){
session
}
}
query me {
deserializeUser{
id,
email,
name
}
}
I found that I can add ./src/graphql.ts:11
const NON_VARIABLE_OPTIONS = ["method", "baseUrl", "url", "headers", "request", "query", "mediaType"]
add a non-variable option operationName
const NON_VARIABLE_OPTIONS = ["method", "baseUrl", "url", "headers", "request", "query", "mediaType","operationName"]
Please give me some clues. Thanks in advance.
It looks like an error you are getting from the GraphQL API, I don't think this is an error with @octokit/graphql
Actually, I can't pass the parameter on the body of operationName. Because the request needs (query and operationName) of a multi operation on the same graphQL.
I have queryFile has multiple operations as the following example:
query login {
createSession(email:"[email protected]", password: "foobar"){
session
}
}
query me {
deserializeUser{
id,
email,
name
}
}
So, I want to use the login
operation for the first time than the me
operation.
const result = await this.auth.graphql( queryFile, operationName );