graphql / vscode-graphql

MIGRATED: VSCode GraphQL extension (autocompletion, go-to definition, syntax highlighting)
https://marketplace.visualstudio.com/items?itemName=Prisma.vscode-graphql
MIT License
557 stars 71 forks source link

Cannot run execute query when adding a fragment to gql tags #143

Closed hmoule closed 4 years ago

hmoule commented 4 years ago

Actual Behavior

No execute query option

export const EXAMPLE_QUERY = gql`
   query exampleQuery {
      ID
      User {
         ...Fragment
     }
   }
 ${fragment}
`;

Expected Behavior

Execute query option with graphql tags

export const EXAMPLE_QUERY = gql`
   Execute query <-----------
   query exampleQuery {
      id
      user {
         ...fragment
     }
   }
 ${fragment}
`;

Steps to Reproduce the Problem Or Description

Specifications

Logs Of TS Server || GraphQL Language Service

acao commented 4 years ago

these features will not work with template tag replacement. there is no graphql parser that will support this, sadly!

maybe in a later version when we have a way to parse graphql this way. apollo's extension has the same issue

jaydenseric commented 4 years ago

This issue has been closed prematurely.

Although it makes sense you can't execute the query when the template string is using interpolation, surely the extension could detect that situation and not display an inline "Execute query" button that has broken functionality.

GraphQL queries in template strings with interpolation is a common, perfectly valid pattern - especially for including fragments like @hmoule displayed in his examples.