apollographql / apollo-tooling

✏️ Apollo CLI for client tooling (Mostly replaced by Rover)
https://apollographql.com
MIT License
3.04k stars 469 forks source link

vscode intellisense not working #2058

Open AlexThomas90210 opened 4 years ago

AlexThomas90210 commented 4 years ago

Intended outcome:

I have a project with the following apollo config in root of project:

// Used for vscode intellisense
module.exports = {
    client: {
        service: {
            name: 'dev',
            localSchemaFile: './prototype/graphql.schema.json'
        }
    }
};

I am using graphql-code-generator to generate an introspection json file at ./prototype/graphql.schema.json

When writing a query document in ./prototype/src/queries/mutations.ts I have the following:

import {gql} from '@apollo/client'

export const putTrack = gql`
  mutation PutProgress($trackId: String!, $currentlyAt: Int!) {
    putProgress(trackId: $trackId, currentlyAt: $currentlyAt) {
      userId
    }
  }
`;

I should get autocomplete options when typing the fields described in the introspection schema linked from the apollo.config.js

Actual outcome:

I get no autocomplete

How to reproduce the issue:

Use localSchemaFile pointing to an introspection schema and try to use autocomplete/intellisense

Versions

vscode "Apollo GraphQL" 1.16.6

VictorGaiva commented 4 years ago

Why is your extension .schema.json? The correct extension should be .gql or .graphql

AlexThomas90210 commented 4 years ago

I am using graphql-codegen to generate an introspection file which is in json, according to the docs here : https://www.apollographql.com/docs/devtools/apollo-config/#option-3-link-a-schema-from-a-local-file , you can specify an introspection file.

I will try with targeting the .graphql files

VictorGaiva commented 4 years ago

Didn't know you could do that. So the issue might be somewhere else. Are you able to post the plugin's logs? You are able to see it by selecting Apollo Graphql in the Output tab on Vscode's terminal.

adamnbowen commented 4 years ago

I've got the same issue with 1.16.7, and this is the only thing that shows up in the Apollo output in VS Code:

------------------------------
🚀 Apollo GraphQL v1.16.7
------------------------------

I'm also using a JSON schema file

malkhuzayyim commented 4 years ago

Having a similar issue. Autocomplete/intellisense not working. just syntax highlighting & formatting is working inside gql tags (not using graphql files), writing queries inside js/vue extension files, both behave the same.

I've been trying to get my apollo vscode extension to autocomplete with intellisense using an introspection query on my Hasura endpoint. Tried everything I can think of, the introspection query is actually hitting my local hasura server with no errors.

But when i inspect the Apollo GraphQL extension outputs with debugging on, while typing inside a gql tag, I still get: Received response 'textDocument/completion - (10)' in 9ms. Result: []

Updated vscode, reloaded, tried everything.

Looking at the output tab, using "show status" I have: 🚀 Apollo GraphQL v1.17.0, and VSCode latest version (1.50.0).

My apollo.config.js file at the root of my project looks like this:

module.exports = {
  client: {
    service: {
      name: "mizan-hasura",
      url: "http://localhost:8080/v1/graphql",
      headers: {
        "x-hasura-admin-secret": "adminsecret",
      },
    },
  },
};

Any insights into getting autocomplete working from introspecting an endpoint would be much appreciated.

VictorGaiva commented 4 years ago

I'm going to leave a recomendation to stop using Apollo Vscode and start using GraphQL for Vscode. It's much more complete

CruelMoney commented 2 years ago

I had an issue where my .graphql files were stored outside of my src directory. This caused IntelliSense to fail. Once I moved everything to the src folder it started working.