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

Custom directives in schema "tried to use an undeclared directive" #686

Open diazoxide opened 10 months ago

diazoxide commented 10 months ago

Custom defined directives from another file not

To Reproduce

  1. Create a new file "directives.graphql"
  2. Add some directive definition e.g.
    directive @Resource(Name: String!, Route: String, Primary: Boolean, DB: DbConfig) on OBJECT
    directive @Field(Label: String, Description: String, DB: DbFieldConfig) on FIELD_DEFINITION
  3. Add directives.graphql to schemas in (graphql.config.yaml or .graphqlrc e.t.c.)
    schema: 
    - "./directives.graphql"
  4. Create new file types.graphql
    type User
    @Resource(Name: "user", Primary: true, Route: "user", DB: {Table: "user"})
    {
    id: ID! @Field(Label: "ID", Description: "ID of the todo", DB: {Column: "id", PrimaryKey: true})
    name: String! @Field(Label: "Text", Description: "Text of the todo", DB: {Column: "name", Unique: true})
    cars: [Car!]! @Field(Label: "Cars", Description: "Cars of the todo", DB: {})
    }
  5. Add types.graphql to schemas too
    schema: 
    - "./directives.graphql"
    - "./types.graphql"
  6. Check inspection errors in editor
image

Version and Environment Details Operation system: MacOS IDE name and version: Goland or Intellij IDEA Plugin version: 4.0.2

vepanimas commented 8 months ago

@diazoxide Hi! Sorry for the late response. Unfortunately, I can't reproduce the issue. My project looks like that, no errors so far.

directives.graphql

directive @Resource(Name: String!, Route: String, Primary: Boolean, DB: DbConfig) on OBJECT
directive @Field(Label: String, Description: String, DB: DbFieldConfig) on FIELD_DEFINITION

types.graphql

input DbConfig {
    Table: String
}

input DbFieldConfig {
    Column: String
    PrimaryKey: Boolean
    Unique: Boolean
}

type Car {
    name: String
}

type User @Resource(Name: "user", Primary: true, Route: "user", DB: {Table: "user"}) {
    id: ID! @Field(Label: "ID", Description: "ID of the todo", DB: {Column: "id", PrimaryKey: true})
    name: String! @Field(Label: "Text", Description: "Text of the todo", DB: {Column: "name", Unique: true})
    cars: [Car!]! @Field(Label: "Cars", Description: "Cars of the todo", DB: {})
}

graphql.config.yml

schema:
  - "./directives.graphql"
  - "./types.graphql"