@pothos/plugin-directives
Advanced tools
Comparing version 3.8.4 to 3.9.0
# Change Log | ||
## 3.9.0 | ||
### Minor Changes | ||
- cd1c0502: Add support for nested lists | ||
## 3.8.4 | ||
@@ -4,0 +10,0 @@ |
/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ /* eslint-disable no-param-reassign */ import './global-types.js'; | ||
import { GraphQLEnumType, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLScalarType, GraphQLUnionType, Kind, parseValue } from 'graphql'; | ||
import { GraphQLEnumType, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLScalarType, GraphQLUnionType, Kind, OperationTypeNode, parseValue } from 'graphql'; | ||
export default function mockAst(schema) { | ||
const types = schema.getTypeMap(); | ||
schema.extensionASTNodes = [ | ||
{ | ||
kind: Kind.SCHEMA_EXTENSION, | ||
directives: directiveNodes(schema.extensions.directives), | ||
operationTypes: [ | ||
{ | ||
operation: OperationTypeNode.QUERY, | ||
node: schema.getQueryType() | ||
}, | ||
{ | ||
operation: OperationTypeNode.MUTATION, | ||
node: schema.getMutationType() | ||
}, | ||
{ | ||
operation: OperationTypeNode.SUBSCRIPTION, | ||
node: schema.getSubscriptionType() | ||
} | ||
].filter(({ node, operation }) => node && node.name !== `${operation[0].toUpperCase()}${operation.slice(1)}`).map(({ operation, node }) => ({ | ||
kind: Kind.OPERATION_TYPE_DEFINITION, | ||
operation, | ||
type: { | ||
kind: Kind.NAMED_TYPE, | ||
name: { | ||
kind: Kind.NAME, | ||
value: node.name | ||
} | ||
} | ||
})) | ||
} | ||
]; | ||
Object.keys(types).forEach((typeName) => { | ||
@@ -6,0 +36,0 @@ const type = types[typeName]; |
@@ -13,2 +13,32 @@ /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ /* eslint-disable no-param-reassign */ "use strict"; | ||
const types = schema.getTypeMap(); | ||
schema.extensionASTNodes = [ | ||
{ | ||
kind: _graphql.Kind.SCHEMA_EXTENSION, | ||
directives: directiveNodes(schema.extensions.directives), | ||
operationTypes: [ | ||
{ | ||
operation: _graphql.OperationTypeNode.QUERY, | ||
node: schema.getQueryType() | ||
}, | ||
{ | ||
operation: _graphql.OperationTypeNode.MUTATION, | ||
node: schema.getMutationType() | ||
}, | ||
{ | ||
operation: _graphql.OperationTypeNode.SUBSCRIPTION, | ||
node: schema.getSubscriptionType() | ||
} | ||
].filter(({ node , operation })=>node && node.name !== `${operation[0].toUpperCase()}${operation.slice(1)}`).map(({ operation , node })=>({ | ||
kind: _graphql.Kind.OPERATION_TYPE_DEFINITION, | ||
operation, | ||
type: { | ||
kind: _graphql.Kind.NAMED_TYPE, | ||
name: { | ||
kind: _graphql.Kind.NAME, | ||
value: node.name | ||
} | ||
} | ||
})) | ||
} | ||
]; | ||
Object.keys(types).forEach((typeName)=>{ | ||
@@ -15,0 +45,0 @@ const type = types[typeName]; |
{ | ||
"name": "@pothos/plugin-directives", | ||
"version": "3.8.4", | ||
"version": "3.9.0", | ||
"description": "Directive plugin for Pothos, enables using graphql-tools based directives with Pothos", | ||
@@ -41,8 +41,8 @@ "main": "./lib/index.js", | ||
"@graphql-tools/utils": "^8.13.0", | ||
"@pothos/core": "3.22.9", | ||
"@pothos/test-utils": "1.4.7", | ||
"graphql": "16.6.0", | ||
"graphql-rate-limit-directive": "^2.0.2", | ||
"graphql-tag": "^2.12.6", | ||
"rate-limiter-flexible": "^2.4.1" | ||
"rate-limiter-flexible": "^2.4.1", | ||
"@pothos/core": "3.23.0", | ||
"@pothos/test-utils": "1.4.7" | ||
}, | ||
@@ -49,0 +49,0 @@ "gitHead": "9dfe52f1975f41a111e01bf96a20033a914e2acc", |
@@ -31,2 +31,3 @@ /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */ | ||
NamedTypeNode, | ||
OperationTypeNode, | ||
parseValue, | ||
@@ -41,2 +42,34 @@ TypeNode, | ||
schema.extensionASTNodes = [ | ||
{ | ||
kind: Kind.SCHEMA_EXTENSION, | ||
directives: directiveNodes(schema.extensions.directives as DirectiveList), | ||
operationTypes: ( | ||
[ | ||
{ | ||
operation: OperationTypeNode.QUERY, | ||
node: schema.getQueryType(), | ||
}, | ||
{ | ||
operation: OperationTypeNode.MUTATION, | ||
node: schema.getMutationType(), | ||
}, | ||
{ | ||
operation: OperationTypeNode.SUBSCRIPTION, | ||
node: schema.getSubscriptionType(), | ||
}, | ||
] as const | ||
) | ||
.filter( | ||
({ node, operation }) => | ||
node && node.name !== `${operation[0].toUpperCase()}${operation.slice(1)}`, | ||
) | ||
.map(({ operation, node }) => ({ | ||
kind: Kind.OPERATION_TYPE_DEFINITION, | ||
operation, | ||
type: { kind: Kind.NAMED_TYPE, name: { kind: Kind.NAME, value: node!.name } }, | ||
})), | ||
}, | ||
]; | ||
Object.keys(types).forEach((typeName) => { | ||
@@ -43,0 +76,0 @@ const type = types[typeName]; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
111694
1603