graphql / graphql/graphql-js

Inconsistent handling of directives in buildASTSchema and buildClientSchema

Open
#3,419 5 comments 3 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
20.3k
Forks
2.1k
Avg merge
44m
Merged PRs (30d)
6

Description

I noticed a difference in how specified (standard) directives are added by `buildASTSchema` vs `buildClientSchema`.

In the former function, the specified directives [are added](https://github.com/graphql/graphql-js/blob/90bd6ff72625173dd39a1f82cfad9336cfad8f65/src/utilities/buildASTSchema.ts#L83) automatically if they are missing.

In the latter function, the specified directives [are not added](https://github.com/graphql/graphql-js/blob/90bd6ff72625173dd39a1f82cfad9336cfad8f65/src/utilities/buildClientSchema.ts#L105) automatically if they are missing.

I think this should be handled in the same way by both method - this different behavior caused some head-scratching [here](https://github.com/graphql-python/gql/issues/278).

The main problem is `buildClientSchema` *not* adding the specified directives. Maybe we can change this to add them, first optionally, and then in the next major version by default?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.