Skip to content

Convert 'GraphQL*Config' to exact types #1391

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

Merged
merged 1 commit into from
Jun 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions src/type/definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ export class GraphQLScalarType {
defineToStringTag(GraphQLScalarType);
defineToJSON(GraphQLScalarType);

export type GraphQLScalarTypeConfig<TInternal, TExternal> = {
export type GraphQLScalarTypeConfig<TInternal, TExternal> = {|
name: string,
description?: ?string,
astNode?: ?ScalarTypeDefinitionNode,
Expand All @@ -599,7 +599,7 @@ export type GraphQLScalarTypeConfig<TInternal, TExternal> = {
valueNode: ValueNode,
variables: ?ObjMap<mixed>,
) => ?TInternal,
};
|};

/**
* Object Type Definition
Expand Down Expand Up @@ -768,15 +768,15 @@ function isValidResolver(resolver: mixed): boolean {
return resolver == null || typeof resolver === 'function';
}

export type GraphQLObjectTypeConfig<TSource, TContext> = {
export type GraphQLObjectTypeConfig<TSource, TContext> = {|
name: string,
interfaces?: Thunk<?Array<GraphQLInterfaceType>>,
fields: Thunk<GraphQLFieldConfigMap<TSource, TContext>>,
isTypeOf?: ?GraphQLIsTypeOfFn<TSource, TContext>,
description?: ?string,
astNode?: ?ObjectTypeDefinitionNode,
extensionASTNodes?: ?$ReadOnlyArray<ObjectTypeExtensionNode>,
};
|};

export type GraphQLTypeResolver<TSource, TContext> = (
value: TSource,
Expand Down Expand Up @@ -823,24 +823,24 @@ export type GraphQLFieldConfig<
TSource,
TContext,
TArgs = { [argument: string]: any },
> = {
> = {|
type: GraphQLOutputType,
args?: GraphQLFieldConfigArgumentMap,
resolve?: GraphQLFieldResolver<TSource, TContext, TArgs>,
subscribe?: GraphQLFieldResolver<TSource, TContext, TArgs>,
deprecationReason?: ?string,
description?: ?string,
astNode?: ?FieldDefinitionNode,
};
|};

export type GraphQLFieldConfigArgumentMap = ObjMap<GraphQLArgumentConfig>;

export type GraphQLArgumentConfig = {
export type GraphQLArgumentConfig = {|
type: GraphQLInputType,
defaultValue?: mixed,
description?: ?string,
astNode?: ?InputValueDefinitionNode,
};
|};

export type GraphQLFieldConfigMap<TSource, TContext> = ObjMap<
GraphQLFieldConfig<TSource, TContext>,
Expand Down Expand Up @@ -934,7 +934,7 @@ export class GraphQLInterfaceType {
defineToStringTag(GraphQLInterfaceType);
defineToJSON(GraphQLInterfaceType);

export type GraphQLInterfaceTypeConfig<TSource, TContext> = {
export type GraphQLInterfaceTypeConfig<TSource, TContext> = {|
name: string,
fields: Thunk<GraphQLFieldConfigMap<TSource, TContext>>,
/**
Expand All @@ -946,7 +946,7 @@ export type GraphQLInterfaceTypeConfig<TSource, TContext> = {
description?: ?string,
astNode?: ?InterfaceTypeDefinitionNode,
extensionASTNodes?: ?$ReadOnlyArray<InterfaceTypeExtensionNode>,
};
|};

/**
* Union Type Definition
Expand Down Expand Up @@ -1025,7 +1025,7 @@ function defineTypes(
return types;
}

export type GraphQLUnionTypeConfig<TSource, TContext> = {
export type GraphQLUnionTypeConfig<TSource, TContext> = {|
name: string,
types: Thunk<Array<GraphQLObjectType>>,
/**
Expand All @@ -1037,7 +1037,7 @@ export type GraphQLUnionTypeConfig<TSource, TContext> = {
description?: ?string,
astNode?: ?UnionTypeDefinitionNode,
extensionASTNodes?: ?$ReadOnlyArray<UnionTypeExtensionNode>,
};
|};

/**
* Enum Type Definition
Expand Down Expand Up @@ -1158,24 +1158,24 @@ function defineEnumValues(
});
}

export type GraphQLEnumTypeConfig /* <T> */ = {
export type GraphQLEnumTypeConfig /* <T> */ = {|
name: string,
values: GraphQLEnumValueConfigMap /* <T> */,
description?: ?string,
astNode?: ?EnumTypeDefinitionNode,
extensionASTNodes?: ?$ReadOnlyArray<EnumTypeExtensionNode>,
};
|};

export type GraphQLEnumValueConfigMap /* <T> */ = ObjMap<
GraphQLEnumValueConfig /* <T> */,
>;

export type GraphQLEnumValueConfig /* <T> */ = {
export type GraphQLEnumValueConfig /* <T> */ = {|
value?: any /* T */,
deprecationReason?: ?string,
description?: ?string,
astNode?: ?EnumValueDefinitionNode,
};
|};

export type GraphQLEnumValue /* <T> */ = {
name: string,
Expand Down Expand Up @@ -1260,20 +1260,20 @@ export class GraphQLInputObjectType {
defineToStringTag(GraphQLInputObjectType);
defineToJSON(GraphQLInputObjectType);

export type GraphQLInputObjectTypeConfig = {
export type GraphQLInputObjectTypeConfig = {|
name: string,
fields: Thunk<GraphQLInputFieldConfigMap>,
description?: ?string,
astNode?: ?InputObjectTypeDefinitionNode,
extensionASTNodes?: ?$ReadOnlyArray<InputObjectTypeExtensionNode>,
};
|};

export type GraphQLInputFieldConfig = {
export type GraphQLInputFieldConfig = {|
type: GraphQLInputType,
defaultValue?: mixed,
description?: ?string,
astNode?: ?InputValueDefinitionNode,
};
|};

export type GraphQLInputFieldConfigMap = ObjMap<GraphQLInputFieldConfig>;

Expand Down
8 changes: 0 additions & 8 deletions src/type/introspection.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import type { GraphQLField } from './definition';

export const __Schema = new GraphQLObjectType({
name: '__Schema',
isIntrospection: true,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 379a308 but doesn't required now.

description:
'A GraphQL Schema defines the capabilities of a GraphQL server. It ' +
'exposes all available types and directives on the server, as well as ' +
Expand Down Expand Up @@ -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.' +
Expand Down Expand Up @@ -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.',
Expand Down Expand Up @@ -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.' +
Expand Down Expand Up @@ -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.',
Expand Down Expand Up @@ -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 ' +
Expand Down Expand Up @@ -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 ' +
Expand Down Expand Up @@ -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: {
Expand Down
1 change: 0 additions & 1 deletion src/utilities/buildClientSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ export function buildClientSchema(
? valueFromAST(parseValue(inputValueIntrospection.defaultValue), type)
: undefined;
return {
name: inputValueIntrospection.name,
description: inputValueIntrospection.description,
type,
defaultValue,
Expand Down