apollo-server-core: Remove inconsistent @cacheControl
auto-definition
#5182
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In Apollo Server 2, ApolloServer sometimes adds the definition of
@cacheControl
to your schema.Specifically, it adds it whenever you rely on the implicit call to
graphql-tools
'makeExecutableSchema
(ie, you passtypeDefs
andresolvers
). It doesn't add it when you pass your ownschema
, andoddly it doesn't add it when you use
modules
.On the other hand, it doesn't care if you actually have cache control
enabled in your app.
What this means is that switching between the implicit call to the
built-in version of
makeExecutableSchema
and using your own copy ofgraphql-tools
has a surprising impact on your schema. We'd like tomake the implicit call just a shorthand and encourage folks who want to
use all of the different options of
makeExecutableSchema
to call itdirectly in their app (rather than having tons of pass-through
arguments), so we don't want the semantics to differ in a surprising and
undocumented way.
Plus, other tools that look at your schema will work better if you
define the
@cacheControl
directive explicitly.AS2 did allow you to define the directive yourself (it only adds it if
it isn't there).
So this PR changes
apollo-server-core
to no longer auto-include thedefinitions, and documents how to write them yourself.
(In the future, we may want to change
@cacheControl
to be a CoreSchema feature, but we're not doing that today.)
(AS2 had a similar issue with the types related to
graphql-upload
butthat integration is removed.)
Fixes #5181.