JetBrains / js-graphql-intellij-plugin

GraphQL language support for WebStorm, IntelliJ IDEA and other IDEs based on the IntelliJ Platform.
https://jimkyndemeyer.github.io/js-graphql-intellij-plugin/
MIT License
879 stars 97 forks source link

Unknown field , android , multi modules #680

Closed Isma3ilMohamed closed 10 months ago

Isma3ilMohamed commented 11 months ago

hey everyone

I'm working on multi module project and have a module for schema

and feature modules for different feature in a project

so while typing any query, mutation or use fragment from schema module it shows me this error

Unknown field "": The parent selection or operation does not resolve to a valid schema type

project build successfully and queries, mutation also generated but file show error on whole stuff and this one for example

image

so i want to know how to fix that in order to could use autocomplete

my android studio version Android Studio Giraffe | 2022.3.1

and the plugin version 4.0.1-222

thanks for all

amrkamal123 commented 11 months ago

same i have the same error !!!

vepanimas commented 10 months ago

@Isma3ilMohamed hi! Do you have any kind of graphql configuration in the project? And could you describe your project structure? Also, are there any graphql errors in the GraphQL tool window?

Isma3ilMohamed commented 10 months ago

@vepanimas thanks for reply I've a multimodule structure such as make a module for schema and inside it i setup my graphql config like that

schema: schema.graphqls
extensions:
  endpoints:
    Default GraphQL Endpoint:
      url: https://example.com/graphql/
      headers:
        user-agent: JS GraphQL
      introspect: false

then I made a separate module depend of features and inside these modules I've used graphql files for queries and mutations

so in schema module everything is fine but in features modules graphql files can't find any query or mutation and give me an error like in the question

about tool window in schema module image

but in any feature modules it didn't show my any configurations image

however that happened in new version but in previous versions it worked

vepanimas commented 10 months ago

@Isma3ilMohamed is the structure of the project something like this?

root
    module1
        schema.graphql
        graphql.config.yml
    module2
        someQuery.graphql
Isma3ilMohamed commented 10 months ago

yes @vepanimas it's exactly like that

root
    module1
          schema.graphql
          graphql.config.yml
          Fragments.graphql
     module2
          someQuery.graphql
     module3
          someQuery.graqhql
          someMutations.graphql

     ....etc
vepanimas commented 10 months ago

@Isma3ilMohamed is it possible to move the config to the root and change the corresponding paths inside of it? Because the plugin can't actually find a schema for module2 and module3. In the previous releases it worked, because the plugin just ignored a config in your case and worked globally for the whole project.

Isma3ilMohamed commented 10 months ago

hey @vepanimas sorry for being late and I made your recommended edits and it works move the configuration file in root and edit schema path like that

schema: schema_module/src/main/graphql/com/example/schema.graphqls
extensions:
  endpoints:
    Default GraphQL Endpoint:
      url: https://example_url.com/graphql/
      headers:
        user-agent: JS GraphQL
      introspect: false

but I've another issue as you see i made a specific file for fragment and need to know if there is anyway to add fragments file path reference to the configuration file in order to be visible for other files in other modules If not possible we could close this issue and thanks so much for your help

vepanimas commented 10 months ago

@Isma3ilMohamed I'm unsure if I understood a question correctly, but it looks like specifying the documents key including your fragments should help. Have you tried it? Something like that:

projects:
  frontend:
    schema: https://my.api.com/graphql
    documents: frontend/**/*.{graphql,js,ts}
    exclude: queries/** 
  backend:
    schema: backend/schema.graphql
    documents: backend/**/*.graphql
Isma3ilMohamed commented 10 months ago

yes that is working with me 👏 thanks @vepanimas for your support