This repository has been archived by the owner on Apr 15, 2020. It is now read-only.
forked from ardatan/graphql-tools
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ci): properly polyfill graphql v14.1 and 14.2
to properly support all graphql versions >= v0.12
- Loading branch information
Showing
20 changed files
with
156 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Source, buildASTSchema, parse, BuildSchemaOptions } from 'graphql'; | ||
|
||
// polyfill for graphql prior to v13 which do not pass options to buildASTSchema | ||
export function buildSchema( | ||
ast: string | Source, | ||
buildSchemaOptions: BuildSchemaOptions, | ||
) { | ||
return buildASTSchema(parse(ast), buildSchemaOptions); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { | ||
DocumentNode, | ||
GraphQLSchema, | ||
extendSchema as graphqlExtendSchema, | ||
} from 'graphql'; | ||
|
||
import { getResolversFromSchema } from '../utils'; | ||
import { IResolverOptions } from '../Interfaces'; | ||
|
||
// polyfill for graphql < v14.2 which does not support subscriptions | ||
export function extendSchema( | ||
schema: GraphQLSchema, | ||
extension: DocumentNode, | ||
options: any, | ||
): GraphQLSchema { | ||
const subscriptionType = schema.getSubscriptionType(); | ||
if (subscriptionType == null) { | ||
return graphqlExtendSchema(schema, extension, options); | ||
} | ||
|
||
const resolvers = getResolversFromSchema(schema); | ||
|
||
const subscriptionTypeName = subscriptionType.name; | ||
const subscriptionResolvers = resolvers[ | ||
subscriptionTypeName | ||
] as IResolverOptions; | ||
|
||
const extendedSchema = graphqlExtendSchema(schema, extension, options); | ||
|
||
const fields = extendedSchema.getSubscriptionType().getFields(); | ||
Object.keys(subscriptionResolvers).forEach(fieldName => { | ||
fields[fieldName].resolve = subscriptionResolvers[fieldName].resolve; | ||
fields[fieldName].subscribe = subscriptionResolvers[fieldName].subscribe; | ||
}); | ||
|
||
return extendedSchema; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export { isSpecifiedScalarType } from './isSpecifiedScalarType'; | ||
|
||
export { buildSchema } from './buildSchema'; | ||
|
||
export { extendSchema } from './extendSchema'; | ||
|
||
export { | ||
toConfig, | ||
schemaToConfig, | ||
typeToConfig, | ||
objectTypeToConfig, | ||
interfaceTypeToConfig, | ||
unionTypeToConfig, | ||
enumTypeToConfig, | ||
scalarTypeToConfig, | ||
inputObjectTypeToConfig, | ||
directiveToConfig, | ||
} from './toConfig'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.