ruanyl / coc-apollo

coc.nvim extension for GraphQL/Apollo GraphQL
MIT License
4 stars 0 forks source link

List variants not found #3

Open AdrienLemaire opened 3 years ago

AdrienLemaire commented 3 years ago

hi @ruanyl , and thanks for keeping adding new features to the plugin <3 Could you also add git tags when releasing ? Since I'm watching the releases for this repo, I'd be able to follow new features as you release them.

I'm now using coc-apollo@0.4.1, and trying to setup my status line (really needed a good way to switch from production to local schema, so many thanks for that!). But I cannot see the variant in my statusline, and debugging further, g:coc_apollo_current_variant doesn't exist and :CocList variants returns [coc.nvim] List variants not found.

In addition, stats stopped showing up on graphql queries.

:CocList variants
[coc.nvim] List variants not found
:CocCommand apollo.reload.variants
[coc.nvim] Command: apollo.reload.variants not found
:CocCommand apollo.reload.stats
[coc.nvim] Command: apollo.reload.stats not foun
:CocList extensions
+ coc-apollo 0.4.1 ~/.config/coc/extensions/node_modules/coc-apollo

.env contains APOLLO_KEY with apollo studio key

.graphqlconfig (Might you be expecting a graphql.config.json instead of a .graphqlconfig file ?)

{
  "schemaPath": "./schema.graphql"
}

.vim/coc-settings.json

{
  ...
  "apollo.enabled": true,
  "apollo.defaultVariant": "current"
}

I noticed that you added Add graphql-config for graphql language server in the Setup requirements, and tried installing it in my repo with npm i -E -D graphql-config, but it doesn't have any effect. Are you expecting a global install ? Why can't coc-apollo install it by itself ?

Looking forward to getting this plugin working back again :smile:

ruanyl commented 3 years ago

Hi @AdrienLemaire, do you have apollo.config in project root? And how it looks like? It looks like the plugin failed to load since the variants list hasn't been registered.

The graphql.config is required by language server, and any valid graphql-config files should work.

Can you run :CocOpenLog and see if there were any errors when startup the editor?

AdrienLemaire commented 3 years ago

@ruanyl thanks for the quick reply

apollo.config.js in project root, dir from which I start vim (not git repo root though)

module.exports = {
  client: {
    name: "Project [web]",
    service: {
      name: "project",
      // This option uses the resulting schema from makeAugmentedSchema
      url: process.env.GRAPHQL_URI || "http://localhost:4001/graphql",
      skipSSLValidation: true,
    },
    excludes: ["**/__tests__/**/*"],
  },
};

CocOpenLog

2021-03-04T18:22:45.595 ERROR (pid:3690615) [extension:coc-apollo] - {
  __schema: {
    queryType: { name: 'Query' },
    mutationType: { name: 'Mutation' },
    subscriptionType: { name: 'Subscription' },
    types: [
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object], [Object], [Object],
      [Object], [Object], [Object], [Object],
      ... 293 more items
    ],
    directives: [
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object]
    ]
  }
}
2021-03-04T18:22:45.792 INFO (pid:3690615) [services] - registered service "coc-apollo"
2021-03-04T18:22:46.144 INFO (pid:3690615) [plugin] - coc.nvim 0.0.80-9184dcccc4 initialized with node: v15.8.0 after 804ms
2021-03-04T18:22:46.395 INFO (pid:3690615) [services] - GraphQL Language Server state change: stopped => starting
2021-03-04T18:22:46.447 INFO (pid:3690615) [language-client-index] - coc-apollo started with 3690705
2021-03-04T18:22:46.457 INFO (pid:3690615) [language-client-index] - eslint started with 3690712
2021-03-04T18:22:46.481 INFO (pid:3690615) [language-client-index] - tailwindCSS started with 3690721
2021-03-04T18:22:46.492 INFO (pid:3690615) [services] - registered service "tsserver"
2021-03-04T18:22:46.696 INFO (pid:3690615) [services] - GraphQL Language Server state change: starting => running
2021-03-04T18:22:46.697 INFO (pid:3690615) [services] - service coc-apollo started
2021-03-04T18:22:53.556 INFO (pid:3690615) [attach] - receive notification: openLog []

Edit: Tried adding "apollo.debug": true, in coc-settings.json to see if logs would be more verbose, but I'm getting the same content in :CocOpenLog afterwards.

ruanyl commented 3 years ago

@AdrienLemaire According to the Apollo documentation

There are 3 types of configuration for a client project

1. Use the Apollo schema registry
2. With a remote endpoint (from a running server)
3. With a local schema file

And your configuration is for 2. With a remote endpoint (from a running server) by intention. which means it will load the schema from the endpoint(client.service.url), NOT from Apollo schema registry. And that's why you didn't see variants list.

To load graphql variants from Apollo, your configuration file should be something like this

module.exports = {
  client: {
    name: "Project [web]",
    service: <the graphql name in apollo schema registry>
  },
};
AdrienLemaire commented 3 years ago

@ruanyl oh I see... I didn't understand what variants meant. I was looking for a way to toggle between the production environment (Apollo schema registry) and my local dev environment (remote endpoint), and thought variants was the solution for this.

This resolves this issue. All I need to do is toggle my config in the apollo.config.js, thanks for the support!

ruanyl commented 3 years ago

So the variants are basically the tags you specified when you publishing the schema to Apollo. But your use case makes sense to me, switching between local/remote/apollo registry is quite usefull

I'll check the official apollo vscode extension and see how it behaves there.

AdrienLemaire commented 3 years ago

Hello @ruanyl ! We finally added a new variant staging to our apollo studio :tada:

I tried to use it in local:

:CocList variants
  current
  staging

When selecting staging and pressing Enter, I get:

[coc.nvim] Failed to load schema of variant: staging

Do you know why this would happen ?