vscode-restclient icon indicating copy to clipboard operation
vscode-restclient copied to clipboard

GraphQL: Support Aliases for queries

Open docwarems opened this issue 3 years ago • 3 comments

In GraphQL playgrounds I can add an alias String to a query (or mutation, or ...). Copying multiple queries from the .http file to a playground results in syntax errors, unless I add the alias there. It would be nice to be able to have the alias support in the .http files too. This also self-documents the query, rather than by adding a comment.

grafik

Only one anonymous query allowed in playground grafik

docwarems avatar Feb 09 '22 15:02 docwarems

@docwarems is this what you want? https://github.com/Huachao/vscode-restclient/issues/919 If so, it's already supported in the latest version 0.24.6

Huachao avatar Feb 10 '22 02:02 Huachao

It probably goes in this direction, but I cannot get it to work, see my comment there. Also what I need is a syntax that is compatible with popular browser GraphQL playgrounds, and I wonder if the proposed solutions satisfies that.

docwarems avatar Feb 10 '22 07:02 docwarems

@docwarems I see the error you've posted in that issue. And it's a known issue, the workaround is removing the traling space between MyAlias and {. And your request should look similar as follows:

POST HTTP://localhost:8090/graphql
Content-Type: application/json
X-Request-Type: GraphQL

query MyAlias{
 ....

In the next release, you can write as you wish that keeps the space

Huachao avatar Feb 10 '22 08:02 Huachao