Graphql-engine: Use with VSCode-graphql

Created on 24 Feb 2019  路  7Comments  路  Source: hasura/graphql-engine

I am trying to use https://github.com/prismagraphql/vscode-graphql for Intellisense autocompletion/in-editor queries etc.

When executing a query using the extension, I get the following error:

Error: Network error: When parsing the constructor GraphQLRequest of type Hasura.GraphQL.Transport.HTTP.Protocol.GraphQLRequest expected Object but got Array.

My .graphqlconfig looks like this:

{
  "projects": {
    "Faberge": {
      "schemaPath": "./schema.graphql",
      "extensions": {
        "endpoints": {
          "default": "http://localhost:8080/v1alpha1/graphql"
        }
      }
    }
  }
}

Is there something more I need to do in order to get the correct response ?

question

Most helpful comment

All 7 comments

@wawhal Have you tried this out with vscode?

@Jayphen I know you asked specifically about stpn.vscode-graphql, but I use apollographql.vscode-apollo, and it works like a charm for me. This is my apollo.config.js file:

module.exports = {
  client: {
    service: {
      name: 'your-project-name',
      url: 'http://localhost:8080/v1alpha1/graphql',
    },
    includes: ['**/queries/**/*.{gql,graphql}'], // change this to your pattern
  },
}

apollo-vscode

PS: you don't need to use Apollo in your project to take advantage of its VS Code extension.

Actually, the extension I was talking about was this one https://github.com/prismagraphql/vscode-graphql. I accidentally posted the wrong link! (I've now updated the original post). The intellisense does work as intended in .gql or .graphql files (that's unrelated to Hasura - it just autocompletes from the static schema)

However, if you attempt to execute the query, it will fail with the error I mentioned above.

@Jayphen What do you mean by execute? You can run the query against the server from VSCode?

Yes, the extension adds an 'execute query' CodeLens link/button: https://github.com/prisma/vscode-graphql/pull/77

codelens

However the response from Hasura seems to be something other than what it is expecting. When it should show the response it instead gives the error

Error: Network error: When parsing the constructor GraphQLRequest of type Hasura.GraphQL.Transport.HTTP.Protocol.GraphQLRequest expected Object but got Array.

I am able to replicate this.
Investigating the problem.

Was this page helpful?
0 / 5 - 0 ratings