-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
Changes from all commits
713ffe2
c7f5088
66d73a8
643d2c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { DocumentNode, DefinitionNode, Kind } from 'graphql'; | ||
|
||
export default function filterExtensionDefinitions(ast: DocumentNode) { | ||
const extensionDefs = ast.definitions.filter( | ||
(def: DefinitionNode) => | ||
def.kind !== Kind.OBJECT_TYPE_EXTENSION && | ||
def.kind !== Kind.INTERFACE_TYPE_EXTENSION && | ||
def.kind !== Kind.INPUT_OBJECT_TYPE_EXTENSION && | ||
def.kind !== Kind.UNION_TYPE_EXTENSION && | ||
def.kind !== Kind.ENUM_TYPE_EXTENSION && | ||
def.kind !== Kind.SCALAR_TYPE_EXTENSION && | ||
def.kind !== Kind.SCHEMA_EXTENSION, | ||
); | ||
|
||
return { | ||
...ast, | ||
definitions: extensionDefs, | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,6 @@ import resolveParentFromTypename from './resolveFromParentTypename'; | |
import defaultMergedResolver from './defaultMergedResolver'; | ||
import { checkResultAndHandleErrors } from './errors'; | ||
import { observableToAsyncIterable } from './observableToAsyncIterable'; | ||
import { Options as PrintSchemaOptions } from 'graphql/utilities/schemaPrinter'; | ||
|
||
export type ResolverFn = ( | ||
rootValue?: any, | ||
|
@@ -49,6 +48,27 @@ export type FetcherOperation = { | |
context?: { [key: string]: any }; | ||
}; | ||
|
||
/** | ||
* This type has been copied inline from its source on `@types/graphql`: | ||
* | ||
* https://git.io/Jv8NX | ||
Comment on lines
+52
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
* | ||
* Previously, it was imported from `graphql/utilities/schemaPrinter`, however | ||
* that module has been removed in `graphql@15`. Furthermore, the sole property | ||
* on this type is due to be deprecated in `graphql@16`. | ||
*/ | ||
interface PrintSchemaOptions { | ||
/** | ||
* Descriptions are defined as preceding string literals, however an older | ||
* experimental version of the SDL supported preceding comments as | ||
* descriptions. Set to true to enable this deprecated behavior. | ||
* This option is provided to ease adoption and will be removed in v16. | ||
* | ||
* Default: false | ||
*/ | ||
commentDescriptions?: boolean; | ||
} | ||
|
||
export default function makeRemoteExecutableSchema({ | ||
schema, | ||
link, | ||
|
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 viaisTypeSystemExtensionNode
, 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 itspeerDependencies
to exclude pre-14.x should be using that predicate though!