Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
diazoxide opened this issue Aug 30, 2023 · 1 comment
Open

Comments

@diazoxide
Copy link

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
  1. Add directives.graphql to schemas in (graphql.config.yaml or .graphqlrc e.t.c.)
schema: 
   - "./directives.graphql"
  1. 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: {})
}
  1. Add types.graphql to schemas too
schema: 
   - "./directives.graphql"
   - "./types.graphql"
  1. 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
Copy link
Collaborator

@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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants