Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"An operation name is required if the query contains multiple operations" #406

Open
Nasr-Ladib opened this issue Sep 22, 2022 · 2 comments
Labels
Type: Support Any questions, information, or general needs around the SDK or GitHub APIs

Comments

@Nasr-Ladib
Copy link

Nasr-Ladib commented Sep 22, 2022

Hi. I am trying to put many queries and fragments inside one request.
My POST request's body:

query login {
  createSession(email:"test@123.com", 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.

@gr2m gr2m added the Type: Support Any questions, information, or general needs around the SDK or GitHub APIs label Sep 23, 2022
@gr2m
Copy link
Contributor

gr2m commented Sep 23, 2022

It looks like an error you are getting from the GraphQL API, I don't think this is an error with @octokit/graphql

@Nasr-Ladib
Copy link
Author

Nasr-Ladib commented Oct 6, 2022

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:"test@123.com", 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 );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Support Any questions, information, or general needs around the SDK or GitHub APIs
Projects
None yet
Development

No branches or pull requests

2 participants