From 8f8a368e8a2c4542755efbbfdb79ec0c4ed49c5c Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Tue, 12 Jun 2018 22:11:04 +0300 Subject: [PATCH] Convert 'GraphQL*Config' to exact types --- src/type/definition.js | 40 +++++++++++++++--------------- src/type/introspection.js | 8 ------ src/utilities/buildClientSchema.js | 1 - 3 files changed, 20 insertions(+), 29 deletions(-) diff --git a/src/type/definition.js b/src/type/definition.js index 2d668a26c2..3613cefde3 100644 --- a/src/type/definition.js +++ b/src/type/definition.js @@ -589,7 +589,7 @@ export class GraphQLScalarType { defineToStringTag(GraphQLScalarType); defineToJSON(GraphQLScalarType); -export type GraphQLScalarTypeConfig = { +export type GraphQLScalarTypeConfig = {| name: string, description?: ?string, astNode?: ?ScalarTypeDefinitionNode, @@ -599,7 +599,7 @@ export type GraphQLScalarTypeConfig = { valueNode: ValueNode, variables: ?ObjMap, ) => ?TInternal, -}; +|}; /** * Object Type Definition @@ -768,7 +768,7 @@ function isValidResolver(resolver: mixed): boolean { return resolver == null || typeof resolver === 'function'; } -export type GraphQLObjectTypeConfig = { +export type GraphQLObjectTypeConfig = {| name: string, interfaces?: Thunk>, fields: Thunk>, @@ -776,7 +776,7 @@ export type GraphQLObjectTypeConfig = { description?: ?string, astNode?: ?ObjectTypeDefinitionNode, extensionASTNodes?: ?$ReadOnlyArray, -}; +|}; export type GraphQLTypeResolver = ( value: TSource, @@ -823,7 +823,7 @@ export type GraphQLFieldConfig< TSource, TContext, TArgs = { [argument: string]: any }, -> = { +> = {| type: GraphQLOutputType, args?: GraphQLFieldConfigArgumentMap, resolve?: GraphQLFieldResolver, @@ -831,16 +831,16 @@ export type GraphQLFieldConfig< deprecationReason?: ?string, description?: ?string, astNode?: ?FieldDefinitionNode, -}; +|}; export type GraphQLFieldConfigArgumentMap = ObjMap; -export type GraphQLArgumentConfig = { +export type GraphQLArgumentConfig = {| type: GraphQLInputType, defaultValue?: mixed, description?: ?string, astNode?: ?InputValueDefinitionNode, -}; +|}; export type GraphQLFieldConfigMap = ObjMap< GraphQLFieldConfig, @@ -934,7 +934,7 @@ export class GraphQLInterfaceType { defineToStringTag(GraphQLInterfaceType); defineToJSON(GraphQLInterfaceType); -export type GraphQLInterfaceTypeConfig = { +export type GraphQLInterfaceTypeConfig = {| name: string, fields: Thunk>, /** @@ -946,7 +946,7 @@ export type GraphQLInterfaceTypeConfig = { description?: ?string, astNode?: ?InterfaceTypeDefinitionNode, extensionASTNodes?: ?$ReadOnlyArray, -}; +|}; /** * Union Type Definition @@ -1025,7 +1025,7 @@ function defineTypes( return types; } -export type GraphQLUnionTypeConfig = { +export type GraphQLUnionTypeConfig = {| name: string, types: Thunk>, /** @@ -1037,7 +1037,7 @@ export type GraphQLUnionTypeConfig = { description?: ?string, astNode?: ?UnionTypeDefinitionNode, extensionASTNodes?: ?$ReadOnlyArray, -}; +|}; /** * Enum Type Definition @@ -1158,24 +1158,24 @@ function defineEnumValues( }); } -export type GraphQLEnumTypeConfig /* */ = { +export type GraphQLEnumTypeConfig /* */ = {| name: string, values: GraphQLEnumValueConfigMap /* */, description?: ?string, astNode?: ?EnumTypeDefinitionNode, extensionASTNodes?: ?$ReadOnlyArray, -}; +|}; export type GraphQLEnumValueConfigMap /* */ = ObjMap< GraphQLEnumValueConfig /* */, >; -export type GraphQLEnumValueConfig /* */ = { +export type GraphQLEnumValueConfig /* */ = {| value?: any /* T */, deprecationReason?: ?string, description?: ?string, astNode?: ?EnumValueDefinitionNode, -}; +|}; export type GraphQLEnumValue /* */ = { name: string, @@ -1260,20 +1260,20 @@ export class GraphQLInputObjectType { defineToStringTag(GraphQLInputObjectType); defineToJSON(GraphQLInputObjectType); -export type GraphQLInputObjectTypeConfig = { +export type GraphQLInputObjectTypeConfig = {| name: string, fields: Thunk, description?: ?string, astNode?: ?InputObjectTypeDefinitionNode, extensionASTNodes?: ?$ReadOnlyArray, -}; +|}; -export type GraphQLInputFieldConfig = { +export type GraphQLInputFieldConfig = {| type: GraphQLInputType, defaultValue?: mixed, description?: ?string, astNode?: ?InputValueDefinitionNode, -}; +|}; export type GraphQLInputFieldConfigMap = ObjMap; diff --git a/src/type/introspection.js b/src/type/introspection.js index 28c3de4029..5f56f72062 100644 --- a/src/type/introspection.js +++ b/src/type/introspection.js @@ -33,7 +33,6 @@ import type { GraphQLField } from './definition'; export const __Schema = new GraphQLObjectType({ name: '__Schema', - isIntrospection: true, description: 'A GraphQL Schema defines the capabilities of a GraphQL server. It ' + 'exposes all available types and directives on the server, as well as ' + @@ -75,7 +74,6 @@ export const __Schema = new GraphQLObjectType({ export const __Directive = new GraphQLObjectType({ name: '__Directive', - isIntrospection: true, description: 'A Directive provides a way to describe alternate runtime execution and ' + 'type validation behavior in a GraphQL document.' + @@ -105,7 +103,6 @@ export const __Directive = new GraphQLObjectType({ export const __DirectiveLocation = new GraphQLEnumType({ name: '__DirectiveLocation', - isIntrospection: true, description: 'A Directive can be adjacent to many parts of the GraphQL language, a ' + '__DirectiveLocation describes one such possible adjacencies.', @@ -187,7 +184,6 @@ export const __DirectiveLocation = new GraphQLEnumType({ export const __Type = new GraphQLObjectType({ name: '__Type', - isIntrospection: true, description: 'The fundamental unit of any GraphQL Schema is the type. There are ' + 'many kinds of types in GraphQL as represented by the `__TypeKind` enum.' + @@ -293,7 +289,6 @@ export const __Type = new GraphQLObjectType({ export const __Field = new GraphQLObjectType({ name: '__Field', - isIntrospection: true, description: 'Object and Interface types are described by a list of Fields, each of ' + 'which has a name, potentially a list of arguments, and a return type.', @@ -327,7 +322,6 @@ export const __Field = new GraphQLObjectType({ export const __InputValue = new GraphQLObjectType({ name: '__InputValue', - isIntrospection: true, description: 'Arguments provided to Fields or Directives and the input fields of an ' + 'InputObject are represented as Input Values which describe their type ' + @@ -360,7 +354,6 @@ export const __InputValue = new GraphQLObjectType({ export const __EnumValue = new GraphQLObjectType({ name: '__EnumValue', - isIntrospection: true, description: 'One possible value for a given Enum. Enum values are unique values, not ' + 'a placeholder for a string or numeric value. However an Enum value is ' + @@ -398,7 +391,6 @@ export const TypeKind = { export const __TypeKind = new GraphQLEnumType({ name: '__TypeKind', - isIntrospection: true, description: 'An enum describing what kind of type a given `__Type` is.', values: { SCALAR: { diff --git a/src/utilities/buildClientSchema.js b/src/utilities/buildClientSchema.js index b86b9bff40..e7e094538a 100644 --- a/src/utilities/buildClientSchema.js +++ b/src/utilities/buildClientSchema.js @@ -333,7 +333,6 @@ export function buildClientSchema( ? valueFromAST(parseValue(inputValueIntrospection.defaultValue), type) : undefined; return { - name: inputValueIntrospection.name, description: inputValueIntrospection.description, type, defaultValue,