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

Files in excludes are still part of schema discovery => "tried to redefine" errors #564

Closed bfelbo closed 1 year ago

bfelbo commented 2 years ago

Describe the bug We use the popular PostGraphile library to export our GraphQL schema. As such, our exported GraphQL schema is our source of truth.

PostGraphile generates the GraphQL schema through a combination of Postgres DB schema and JS code extending the schema. These GraphQL schema extensions defined in JS are part of the exported schema. However, despite marking these plugins as excludes (e.g. "excludes": ["src/api/plugins/**"]), they're still included in schema discovery, thereby causing type tried to redefine field errors.

Expected behavior Any files in excludes should not be included in schema discovery.

vepanimas commented 2 years ago

Hi! Could you please provide a bit more details about the project structure and config files you have?

bfelbo commented 2 years ago

Sure! Here's our full config file:

{
  "projects": {
    "api": {
      "schemaPath": "build/postgraphile_schema.graphql",
      "excludes": ["src/api/plugins/**"]
    }
  }
}

We only have a single schema and it's fully specified in build/postgraphile_schema.graphql. Since the GraphQL schema is specified through our DB and JS code, the code inside src/api/plugins/** has duplicate GraphQL schema definitions to the fully-exported schema in build/postgraphile_schema.graphql.

vepanimas commented 2 years ago

Both src and build are on the same level in the FS, and the .graphqlconfig is also in the same folder?

vepanimas commented 2 years ago

I mean does it have this structure or something more complicated?

/root
    /build
    /src
    .graphqlconfig

And also, could you please try to write a configuration file that way first (without projects):

{
    "schemaPath": "build/postgraphile_schema.graphql",
    "excludes": [
        "src/api/plugins/**"
    ]
}

and next

{
    "schemaPath": "build/postgraphile_schema.graphql",
    "excludes": [
        "./src/api/plugins/**"
    ]
}

Does it prevent type conflicts?

bfelbo commented 2 years ago

Both src and build are on the same level in the FS, and the .graphqlconfig is also in the same folder? mean does it have this structure or something more complicated?

Yes, that's the structure.

Thanks for providing those configs. However, they don't seem to work. See screenshot below, especially the message saying The .graphqlconfig associated with this file does not include it. Schema discovery and language tooling will use entire project.

image

DamodarSojka commented 2 years ago

Facing similar issues. Is there any update on this?

nilshartmann commented 1 year ago

Same here, schemaPath seems to be completly ignored and all graphql schema files in any subfolder of the directory containing the .graphqlconfig file are read.

What seems to work 🙏:

{
  "name": "Publy WS Backend",
  "schemaPath": "./publy-backend/src/main/resources/graphql/publy.graphqls",
  "includes": ["./**/*.graphql"]
}