graphql / graphql/graphql-spec
Directives inheritance on field implemented from an interface
- Dominant language
- JavaScript
- Stars
- 14.6k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
I am currently working on a Python implementation of the GraphQL specification (cf. [`tartiflette`](https://github.com/tartiflette/tartiflette)) which bases its developer experience on directives.
However, we encounter a problem regarding directives applied to fields of an interface implemented by an object. To be more explicit, let's take the following SDL as an example:
```graphql
directive @directiveA(argA: String!, argB: String! = "default") on FIELD_DEFINITION
directive @directiveB on FIELD_DEFINITION
interface Identifiable {
id: ID! @directiveA(argA: "id")
}
type Foo implements Identifiable {
id: ID! @directiveA(argA: "id")
}
type Bar implements Identifiable {
id: ID! @directiveA(argA: "id", argB: "default")
}
type Baz implements Identifiable {
id: ID!
}
type Fum implements Identifiable {
id: ID! @directiveA(argA: "id") @directiveB(argA: "id")
}
type Qux implements Identifiable {
id: ID! @directiveB
}
```
According to the [GraphQL specification](https://spec.graphql.org/June2018/#sec-Objects) (and the reference [`graphql-js`](https://github.com/graphql/graphql-js/blob/4f26a6bc28032c068b4db7207ef077aec7c89902/src/type/validate.js#L332) implementation) all of these object types are valid.
However, in my opinion, not to verify the implementation of directives on objects field makes the SDL and therefore the schema ambiguous.
Is this a wanted behavior or an oversight in the algorithm for checking the fields implementation of an interface by an object?
In our case, we are stuck because we don't know how to handle this case in our implementation (merging directives, raising validation errors, handling only field definition and don't inherit from the field interface...).
Having found no information in the documentation or issue related to this subject I would like to know if someone would possibly have more information to provide me on this point, it would be greatly apprciated 🙏
Contributor guide
Assessment
This issue has not been assessed yet.