Skip to content

Directives and astNodeΒ #681

@rostislavv

Description

@rostislavv

Describe the Bug
When using graphql-modules with type-graphql and @Directive decorator functionality - unexpected behaviour was spotted.

It turned down to printSchemaWithDirectives function from graphql-tools.
Specifically this and this place.
It seems that astNode representation in type-graphql has slight mismatch between one produced by makeExecutableSchema, affecting (in this case) type-graphql and graphql-modules integration (specifically for directives).

To Reproduce
It has the following effect - directives on type and on input are present, but on their fields - they are lost.

  1. Case of type Query:
    type-Query

where result was created by makeExecutableSchema (from graphql-tools also), and buildedSchema was created by buildSchemaSync.
In this case type-graphql's version don't have astNode for type Query. Thus this place is omitted (due to undefined) and fields of type Query lost their directives meta. This probably will take place for type Mutation, and for type Subscription too.

  1. Custom type case:
    custom-type
    in type-graphql's version there are no astNode.fields - which prevents this part of handling directives.

Expected Behavior
astNode of type and root types exists, and it provides fields (if present) to avoid directives lost in case of usage with other libraries (this affects graphql-tools and graphql-modules, but might affect others, if they are using graphql-tools).

If you agree with this change - i'll try to prepare PR.

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions