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

`Execute Query` does not work if the fragment mentioned in the query is not defined below the query definition #133

Closed ma-petrovic closed 4 years ago

ma-petrovic commented 5 years ago

Actual Behavior

Even though Go to definition works, this happens when attempting to Execute Query which uses a fragment

First scenario

query users {
  users {
    ...CompleteUser
  }
}

Results in Error: Network error: Response not successful: Received status code 400

Second scenario

fragment CompleteUser on User {
  id
  name
  lastname
}

query users {
  users {
    ...CompleteUser
  }
}

Results in a blank result with the following log

NetworkHelper: operation: undefined
NetworkHelper: endpoint: http://localhost:4000

Third scenario

query users {
  users {
    ...CompleteUser
  }
}

fragment CompleteUser on User {
  id
  name
  lastname
}

Results in a successful response

{
  "data": {
    "users": [
      {
        "id": "4192cd57-6236-4f8c-a96e-58ff9d53170e",
        "name": "A",
        "lastname": "B"
      },
      {
        "id": "9e22679b-7208-4d21-a906-ad3578baf9bb",
        "name": "C",
        "lastname": "D"
      },
      {
        "id": "f4a920d7-ed1a-4590-8c49-34087c52492f",
        "name": "E",
        "lastname": "F"
      }
    ]
  }
}

Expected Behavior

Query executes successfully and returns the according data

Steps to Reproduce the Problem Or Description

query users {
  users {
    ...CompleteUser
  }
}

# ...

Specifications

Logs Of TS Server || GraphQL Language Service

NetworkHelper: operation: query
NetworkHelper: endpoint: http://localhost:4000
ma-petrovic commented 5 years ago

Additionally, adding a second fragment below causes the same error, i.e.:

query users {
  users {
    ...CompleteUser
  }
}

# ...

fragment CompleteUser on User {
  id
  name
  lastname
}

fragment NjamBase on Njam {
  id
  location
  time
  ordered
}
acao commented 4 years ago

@ma-petrovic if this is still an issue in 0.3.1, can you open a ticket in graphql/graphiql repo? thank you!