Altair: Allow setting operationName

Created on 6 Jun 2018  路  7Comments  路  Source: imolorhe/altair

In graphQL, you can define multiple queries and mutations at once and then while executing you can send the parameter "operationName" to set which operation you want to execute.

For example, the body.query could look like this:

query projects{
  projects{
    name
    id
  }
}

mutation add_new_project{
  new_project(name:"Project", title:"Something"){
    id
  }
}

And then set body.operationName to either add_new_project or projects.

I suggest adding a field somewhere to set this, or do as graphiql does, which opens a pop-up upon clicking execution.

Medium enhancement

All 7 comments

Thanks for reporting this! I'd look into it as soon as I can

@MCSH what is the point of doing that in practice? I'm a little confused why that capability exists, since it entails sending extra bytes to the server that never get used. Unless I misunderstand something?

We use JWT for authentication and authorization.

The best practice is sending it in the header (the other option being sending it as a parameter in every query / mutation - which I don't like) using the Bearer schema.

There could be other uses as well. @jedwards1211

@MCSH Wouldn't the header option work for you?

I'm so sorry. I got confused. I was testing way too many graphql implementations that I confused this one with another one. The header option works fine in altair...

I'm not sure about point of this in production, I seriously doubt I'm gonna use a graphiql implementation in production other than to demo the API (or test it) in which case it is really handy if I didn't have to type entire queries and just select which one I want to run! @jedwards1211

Thx for directing me to this request, @imolorhe . Sorry I did not realize that there was already a change request open for this functionality.

Regarding UX suggestions for how to accomplish this, I'd like to see a dropdown picker appear underneath the 'Send Request' button when it's detected that there is more than one named query in the window, and then you'd click the one that you'd like to submit.

In addition, it would be nice to be able to run the one that the cursor is currently on when pressing Cmd+Enter. If this were easier to implement, I'd be fine doing without the drop-down picker in favor of this.

Thank you

I'm going with the dropdown functionality for now. Further improvements can be made to it later on. PRs are also welcome too!

Was this page helpful?
0 / 5 - 0 ratings