Apollo VSCode plugin errors when autocompleting subscriptions

I’m generating an introspection schema from a /graphql endpoint using import {getIntrospectionQuery} from 'graphql';.

If I save that result as a json file and use it to power apollo vscode, then I get intellisense on all my graphql queries, yay! But… with the latest release of subscriptions I wanted to try them out and see what’s available.

I try and trigger intellisense within a subscription block:

subscription MySubscription() {
   // Here...
}

and nothing happens. At least, I don’t get any of the normal suspects.

In the Apollo GraphQL output window, every time I try to trigger intellisense I get:

[Error - 3:22:22 PM] Request textDocument/completion failed.
  Message: Request textDocument/completion failed with message: Cannot read property 'getFields' of undefined
  Code: -32603 

Not sure what’s displeasing the Apollo gods now… they sure seem fickle!

1 Like

@MichelDiz, can you please look into this?

1 Like

Are you referring VSCode plugin: Apollo GraphQL - Visual Studio Marketplace ?

Yep that’s the one!

Have since switched to using our own dgraph cluster from slash graphql, and upgraded to the latest version of dgraph 20.0.7… still getting the same issue!

Actually, after further playing with

@withSubscription

I got it working… I realised when I added the tag, sometimes the schema update would fail with an unspecified error:

0] {"errors":[{"message":"resolving updateGQLSchema failed because rpc error: code = Unknown desc = error occurred updating GraphQL schema, please retry: Transaction has been aborted. Please retry","locations":[{"line":2,"column":5}]}],"data":{"updateGQLSchema":null},"extensions":{"tracing":{"version":1,"startTime":"2020-09-06T05:16:00.271019877Z","endTime":"2020-09-06T05:16:00.362229691Z","duration":91209824}}}

But after flipping the decorator on and off a few times, it eventually worked. Not sure what was wrong, I didn’t really do anything differently.

But at least now it works!