-
-
Notifications
You must be signed in to change notification settings - Fork 821
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
compat: minimal changes to support graphql@15 within Apollo Server #1284
Conversation
This option will likely be deprecated in `graphql@16`. For now, we'll inline this type into this module to continue emitting it into the declaration file for `makeRemoteExecutableSchema`. This is necessary since the TypeScript compiler can no longer resolve its previous location as `graphql` has moved the location of the `schemaPrinter` module to `printSchema` in graphql/graphql-js#2426. cc @IvanGoncharov
This wouldn't be necessary if this project had a `package-lock.json`, but...
.@IvanGoncharov originally brought this to my attention when he pointed me to yaacovCR#32 (comment) and suggested stripping extension nodes prior to invoking `buildASTSchema` as a cross-version (v14 <=> v15) approach for interim compatibility on the v4 series of `graphql-tools`. The most urgent and pertinent need here from my perspective is to allow user-exploration of the new `graphql@15` release candidate within Apollo Server which currently re-exports the entirety of `graphql-tools` (even though it only relies on small portions of it). Upon further investigation of the above-referenced issue, it appears that @yaacovCR had already crafted the solution that @IvanGoncharov had suggested to me, which I found in 2280eef within the well-organized #1206 (which I am thankful for the continued updates on!). My commit here merely grabs a sub-set of that commit that seemed most pertinent; I certainly don't claim that this solution is nearly as comprehensive as the original 2280eef. My hope is that by using the same code/implementation here, it will marginally lessen future merge conflicts. Since this is basically a re-working of @yaacovCR's commit, I've attributed co-authorship of this commit accordingly. (Thank you, again!) Ref: #1272 Co-authored-by: yaacovCR <yaacovCR@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments, non-blocking. LGTM!
import { DocumentNode, DefinitionNode, Kind } from 'graphql'; | ||
|
||
export default function filterExtensionDefinitions(ast: DocumentNode) { | ||
const extensionDefs = ast.definitions.filter( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
graphql-js
actually provides us this exact filter predicate via isTypeSystemExtensionNode
, can we use that here instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered that, but that predicate wasn't introduced until, I think, 14.0.0. I do think that any version of graphql-tools
that has narrowed its peerDependencies
to exclude pre-14.x should be using that predicate though!
* This type has been copied inline from its source on `@types/graphql`: | ||
* | ||
* https://git.io/Jv8NX |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@types/graphql
is no longer being kept up, but it seems the same type is available in the source still? We could also copy/reference from there if not, so the reference is current.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside from the name, the reference is current. Referencing it from the new location could be a problem for cross-graphql version compatibility, so keeping it in line here seems okay for now.
Is this considered minimally supporting graphql v15 without supporting interfaces that implement interfaces? These changes would support graphql v14 compliant schemas running on higher versions of graphql. Still important, of course, but not the same thing. It was not incredibly hard to add support for interfaces implementing interfaces, I think you should consider it. |
@yaacovCR That's correct. I think that supporting newer The intent/motivation here from my perspective is to make sure that when v15 comes out and folks who are using Apollo Server (which is responsible for a substantial portion of the downloads of Keeping things just the same seems like a good first step since, while end-users might have compelling reason to update to Anyhow, all of that said, I still want to consider bringing in support for interfaces implementing interfaces to I'll merge and release this for now, but happy to open another small PR that brings that long so long as it's compatible with the |
You can't just copy changes in terms of interfaces implementing interfaces from the fork because of my unification of the different transform schema processes. You just have to go through the different places where interfaces are accessed or set up on objects and make sure that they are also done so on interfaces as well. You can use my changes as guide, however. |
Some minimal compatibility changes (see commits for additional clarity) to
prepare for
graphql@15
, which is currently in release candidate stages.I should note that this PR doesn't attempt to get close to the more
comprehensive set of changes which @yaacovCR's
#1206 brings.
Instead, I'm aiming to provide the minimum compatibility with the least number of breaking changes
in order to continue to support Apollo Server v2, which completely re-exports
the current
graphql-tools@4
version.Future versions of Apollo Server will lessen their reliance on this
graphql-tools
package and will also deprecate older versions ofgraphql
which are still supported by it today (including 0.13.x versions). In the
meantime, I hope this will allow the v2 series of Apollo Server to make it
through
graphql@15
. (I do not have this same expecation forgraphql@16
,and we expect to make changes in Apollo Server 3.x which speak to that.)
I've copied and pasted some of my commit log messages here which are included
in this PR: