Skip to content

Commit

Permalink
Revert named extension types in Flow
Browse files Browse the repository at this point in the history
  • Loading branch information
benjie committed Jun 20, 2020
1 parent aa6ddc6 commit 2dbc5ca
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 83 deletions.
12 changes: 0 additions & 12 deletions src/index.js
Expand Up @@ -140,44 +140,32 @@ export type {
GraphQLNamedType,
Thunk,
GraphQLSchemaConfig,
GraphQLSchemaExtensions,
GraphQLDirectiveConfig,
GraphQLDirectiveExtensions,
GraphQLArgument,
GraphQLArgumentConfig,
GraphQLArgumentExtensions,
GraphQLEnumTypeConfig,
GraphQLEnumTypeExtensions,
GraphQLEnumValue,
GraphQLEnumValueConfig,
GraphQLEnumValueExtensions,
GraphQLEnumValueConfigMap,
GraphQLField,
GraphQLFieldConfig,
GraphQLFieldExtensions,
GraphQLFieldConfigArgumentMap,
GraphQLFieldConfigMap,
GraphQLFieldMap,
GraphQLFieldResolver,
GraphQLInputField,
GraphQLInputFieldConfig,
GraphQLInputFieldExtensions,
GraphQLInputFieldConfigMap,
GraphQLInputFieldMap,
GraphQLInputObjectTypeConfig,
GraphQLInputObjectTypeExtensions,
GraphQLInterfaceTypeConfig,
GraphQLInterfaceTypeExtensions,
GraphQLIsTypeOfFn,
GraphQLObjectTypeConfig,
GraphQLObjectTypeExtensions,
GraphQLResolveInfo,
ResponsePath,
GraphQLScalarTypeConfig,
GraphQLScalarTypeExtensions,
GraphQLTypeResolver,
GraphQLUnionTypeConfig,
GraphQLUnionTypeExtensions,
GraphQLScalarSerializer,
GraphQLScalarValueParser,
GraphQLScalarLiteralParser,
Expand Down
72 changes: 26 additions & 46 deletions src/type/definition.js
Expand Up @@ -548,8 +548,6 @@ function undefineIfEmpty<T>(arr: ?$ReadOnlyArray<T>): ?$ReadOnlyArray<T> {
return arr && arr.length > 0 ? arr : undefined;
}
export type GraphQLScalarTypeExtensions = ReadOnlyObjMap<mixed>;

/**
* Scalar Type Definition
*
Expand Down Expand Up @@ -581,7 +579,7 @@ export class GraphQLScalarType {
serialize: GraphQLScalarSerializer<mixed>;
parseValue: GraphQLScalarValueParser<mixed>;
parseLiteral: GraphQLScalarLiteralParser<mixed>;
extensions: ?GraphQLScalarTypeExtensions;
extensions: ?ReadOnlyObjMap<mixed>;
astNode: ?ScalarTypeDefinitionNode;
extensionASTNodes: ?$ReadOnlyArray<ScalarTypeExtensionNode>;

Expand Down Expand Up @@ -626,7 +624,7 @@ export class GraphQLScalarType {
serialize: GraphQLScalarSerializer<mixed>,
parseValue: GraphQLScalarValueParser<mixed>,
parseLiteral: GraphQLScalarLiteralParser<mixed>,
extensions: ?GraphQLScalarTypeExtensions,
extensions: ?ReadOnlyObjMap<mixed>,
extensionASTNodes: $ReadOnlyArray<ScalarTypeExtensionNode>,
|} {
return {
Expand Down Expand Up @@ -682,13 +680,11 @@ export type GraphQLScalarTypeConfig<TInternal, TExternal> = {|
parseValue?: GraphQLScalarValueParser<TInternal>,
// Parses an externally provided literal value to use as an input.
parseLiteral?: GraphQLScalarLiteralParser<TInternal>,
extensions?: ?GraphQLScalarTypeExtensions,
extensions?: ?ReadOnlyObjMapLike<mixed>,
astNode?: ?ScalarTypeDefinitionNode,
extensionASTNodes?: ?$ReadOnlyArray<ScalarTypeExtensionNode>,
|};

export type GraphQLObjectTypeExtensions = ReadOnlyObjMap<mixed>;

/**
* Object Type Definition
*
Expand Down Expand Up @@ -730,7 +726,7 @@ export class GraphQLObjectType {
name: string;
description: ?string;
isTypeOf: ?GraphQLIsTypeOfFn<any, any>;
extensions: ?GraphQLObjectTypeExtensions;
extensions: ?ReadOnlyObjMap<mixed>;
astNode: ?ObjectTypeDefinitionNode;
extensionASTNodes: ?$ReadOnlyArray<ObjectTypeExtensionNode>;

Expand Down Expand Up @@ -773,7 +769,7 @@ export class GraphQLObjectType {
...GraphQLObjectTypeConfig<any, any>,
interfaces: Array<GraphQLInterfaceType>,
fields: GraphQLFieldConfigMap<any, any>,
extensions: ?GraphQLObjectTypeExtensions,
extensions: ?ReadOnlyObjMap<mixed>,
extensionASTNodes: $ReadOnlyArray<ObjectTypeExtensionNode>,
|} {
return {
Expand Down Expand Up @@ -918,7 +914,7 @@ export type GraphQLObjectTypeConfig<TSource, TContext> = {|
interfaces?: Thunk<?Array<GraphQLInterfaceType>>,
fields: Thunk<GraphQLFieldConfigMap<TSource, TContext>>,
isTypeOf?: ?GraphQLIsTypeOfFn<TSource, TContext>,
extensions?: ?GraphQLObjectTypeExtensions,
extensions?: ?ReadOnlyObjMapLike<mixed>,
astNode?: ?ObjectTypeDefinitionNode,
extensionASTNodes?: ?$ReadOnlyArray<ObjectTypeExtensionNode>,
|};
Expand Down Expand Up @@ -971,7 +967,7 @@ export type GraphQLFieldConfig<
resolve?: GraphQLFieldResolver<TSource, TContext, TArgs>,
subscribe?: GraphQLFieldResolver<TSource, TContext, TArgs>,
deprecationReason?: ?string,
extensions?: ?GraphQLFieldExtensions,
extensions?: ?ReadOnlyObjMapLike<mixed>,
astNode?: ?FieldDefinitionNode,
|};

Expand All @@ -981,16 +977,14 @@ export type GraphQLArgumentConfig = {|
description?: ?string,
type: GraphQLInputType,
defaultValue?: mixed,
extensions?: ?GraphQLArgumentExtensions,
extensions?: ?ReadOnlyObjMapLike<mixed>,
astNode?: ?InputValueDefinitionNode,
|};

export type GraphQLFieldConfigMap<TSource, TContext> = ObjMap<
GraphQLFieldConfig<TSource, TContext>,
>;

export type GraphQLFieldExtensions = ReadOnlyObjMap<mixed>;

export type GraphQLField<
TSource,
TContext,
Expand All @@ -1004,18 +998,16 @@ export type GraphQLField<
subscribe?: GraphQLFieldResolver<TSource, TContext, TArgs>,
isDeprecated: boolean,
deprecationReason: ?string,
extensions: ?GraphQLFieldExtensions,
extensions: ?ReadOnlyObjMap<mixed>,
astNode: ?FieldDefinitionNode,
|};

export type GraphQLArgumentExtensions = ReadOnlyObjMap<mixed>;

export type GraphQLArgument = {|
name: string,
description: ?string,
type: GraphQLInputType,
defaultValue: mixed,
extensions: ?GraphQLArgumentExtensions,
extensions: ?ReadOnlyObjMap<mixed>,
astNode: ?InputValueDefinitionNode,
|};

Expand All @@ -1027,8 +1019,6 @@ export type GraphQLFieldMap<TSource, TContext> = ObjMap<
GraphQLField<TSource, TContext>,
>;

export type GraphQLInterfaceTypeExtensions = ReadOnlyObjMap<mixed>;

/**
* Interface Type Definition
*
Expand All @@ -1051,7 +1041,7 @@ export class GraphQLInterfaceType {
name: string;
description: ?string;
resolveType: ?GraphQLTypeResolver<any, any>;
extensions: ?GraphQLInterfaceTypeExtensions;
extensions: ?ReadOnlyObjMap<mixed>;
astNode: ?InterfaceTypeDefinitionNode;
extensionASTNodes: ?$ReadOnlyArray<InterfaceTypeExtensionNode>;

Expand Down Expand Up @@ -1094,7 +1084,7 @@ export class GraphQLInterfaceType {
...GraphQLInterfaceTypeConfig<any, any>,
interfaces: Array<GraphQLInterfaceType>,
fields: GraphQLFieldConfigMap<any, any>,
extensions: ?GraphQLInterfaceTypeExtensions,
extensions: ?ReadOnlyObjMap<mixed>,
extensionASTNodes: $ReadOnlyArray<InterfaceTypeExtensionNode>,
|} {
return {
Expand Down Expand Up @@ -1137,13 +1127,11 @@ export type GraphQLInterfaceTypeConfig<TSource, TContext> = {|
* Object type.
*/
resolveType?: ?GraphQLTypeResolver<TSource, TContext>,
extensions?: ?GraphQLInterfaceTypeExtensions,
extensions?: ?ReadOnlyObjMapLike<mixed>,
astNode?: ?InterfaceTypeDefinitionNode,
extensionASTNodes?: ?$ReadOnlyArray<InterfaceTypeExtensionNode>,
|};

export type GraphQLUnionTypeExtensions = ReadOnlyObjMap<mixed>;

/**
* Union Type Definition
*
Expand Down Expand Up @@ -1171,7 +1159,7 @@ export class GraphQLUnionType {
name: string;
description: ?string;
resolveType: ?GraphQLTypeResolver<any, any>;
extensions: ?GraphQLUnionTypeExtensions;
extensions: ?ReadOnlyObjMap<mixed>;
astNode: ?UnionTypeDefinitionNode;
extensionASTNodes: ?$ReadOnlyArray<UnionTypeExtensionNode>;

Expand Down Expand Up @@ -1204,7 +1192,7 @@ export class GraphQLUnionType {
toConfig(): {|
...GraphQLUnionTypeConfig<any, any>,
types: Array<GraphQLObjectType>,
extensions: ?GraphQLUnionTypeExtensions,
extensions: ?ReadOnlyObjMap<mixed>,
extensionASTNodes: $ReadOnlyArray<UnionTypeExtensionNode>,
|} {
return {
Expand Down Expand Up @@ -1256,13 +1244,11 @@ export type GraphQLUnionTypeConfig<TSource, TContext> = {|
* Object type.
*/
resolveType?: ?GraphQLTypeResolver<TSource, TContext>,
extensions?: ?GraphQLUnionTypeExtensions,
extensions?: ?ReadOnlyObjMapLike<mixed>,
astNode?: ?UnionTypeDefinitionNode,
extensionASTNodes?: ?$ReadOnlyArray<UnionTypeExtensionNode>,
|};

export type GraphQLEnumTypeExtensions = ReadOnlyObjMap<mixed>;

/**
* Enum Type Definition
*
Expand All @@ -1287,7 +1273,7 @@ export type GraphQLEnumTypeExtensions = ReadOnlyObjMap<mixed>;
export class GraphQLEnumType /* <T> */ {
name: string;
description: ?string;
extensions: ?GraphQLEnumTypeExtensions;
extensions: ?ReadOnlyObjMap<mixed>;
astNode: ?EnumTypeDefinitionNode;
extensionASTNodes: ?$ReadOnlyArray<EnumTypeExtensionNode>;

Expand Down Expand Up @@ -1373,7 +1359,7 @@ export class GraphQLEnumType /* <T> */ {

toConfig(): {|
...GraphQLEnumTypeConfig,
extensions: ?GraphQLEnumTypeExtensions,
extensions: ?ReadOnlyObjMap<mixed>,
extensionASTNodes: $ReadOnlyArray<EnumTypeExtensionNode>,
|} {
const values = keyValMap(
Expand Down Expand Up @@ -1459,7 +1445,7 @@ export type GraphQLEnumTypeConfig /* <T> */ = {|
name: string,
description?: ?string,
values: GraphQLEnumValueConfigMap /* <T> */,
extensions?: ?GraphQLEnumTypeExtensions,
extensions?: ?ReadOnlyObjMapLike<mixed>,
astNode?: ?EnumTypeDefinitionNode,
extensionASTNodes?: ?$ReadOnlyArray<EnumTypeExtensionNode>,
|};
Expand All @@ -1470,24 +1456,20 @@ export type GraphQLEnumValueConfig /* <T> */ = {|
description?: ?string,
value?: any /* T */,
deprecationReason?: ?string,
extensions?: ?GraphQLEnumValueExtensions,
extensions?: ?ReadOnlyObjMapLike<mixed>,
astNode?: ?EnumValueDefinitionNode,
|};

export type GraphQLEnumValueExtensions = ReadOnlyObjMap<mixed>;

export type GraphQLEnumValue /* <T> */ = {|
name: string,
description: ?string,
value: any /* T */,
isDeprecated: boolean,
deprecationReason: ?string,
extensions: ?GraphQLEnumValueExtensions,
extensions: ?ReadOnlyObjMap<mixed>,
astNode: ?EnumValueDefinitionNode,
|};

export type GraphQLInputObjectTypeExtensions = ReadOnlyObjMap<mixed>;

/**
* Input Object Type Definition
*
Expand All @@ -1511,7 +1493,7 @@ export type GraphQLInputObjectTypeExtensions = ReadOnlyObjMap<mixed>;
export class GraphQLInputObjectType {
name: string;
description: ?string;
extensions: ?GraphQLInputObjectTypeExtensions;
extensions: ?ReadOnlyObjMap<mixed>;
astNode: ?InputObjectTypeDefinitionNode;
extensionASTNodes: ?$ReadOnlyArray<InputObjectTypeExtensionNode>;

Expand All @@ -1538,7 +1520,7 @@ export class GraphQLInputObjectType {
toConfig(): {|
...GraphQLInputObjectTypeConfig,
fields: GraphQLInputFieldConfigMap,
extensions: ?GraphQLInputObjectTypeExtensions,
extensions: ?ReadOnlyObjMap<mixed>,
extensionASTNodes: $ReadOnlyArray<InputObjectTypeExtensionNode>,
|} {
const fields = mapValue(this.getFields(), (field) => ({
Expand Down Expand Up @@ -1605,7 +1587,7 @@ export type GraphQLInputObjectTypeConfig = {|
name: string,
description?: ?string,
fields: Thunk<GraphQLInputFieldConfigMap>,
extensions?: ?GraphQLInputObjectTypeExtensions,
extensions?: ?ReadOnlyObjMapLike<mixed>,
astNode?: ?InputObjectTypeDefinitionNode,
extensionASTNodes?: ?$ReadOnlyArray<InputObjectTypeExtensionNode>,
|};
Expand All @@ -1614,20 +1596,18 @@ export type GraphQLInputFieldConfig = {|
description?: ?string,
type: GraphQLInputType,
defaultValue?: mixed,
extensions?: ?GraphQLInputFieldExtensions,
extensions?: ?ReadOnlyObjMapLike<mixed>,
astNode?: ?InputValueDefinitionNode,
|};

export type GraphQLInputFieldConfigMap = ObjMap<GraphQLInputFieldConfig>;

export type GraphQLInputFieldExtensions = ReadOnlyObjMap<mixed>;

export type GraphQLInputField = {|
name: string,
description: ?string,
type: GraphQLInputType,
defaultValue: mixed,
extensions: ?GraphQLInputFieldExtensions,
extensions: ?ReadOnlyObjMap<mixed>,
astNode: ?InputValueDefinitionNode,
|};

Expand Down
8 changes: 3 additions & 5 deletions src/type/directives.js
Expand Up @@ -42,8 +42,6 @@ export function assertDirective(directive: mixed): GraphQLDirective {
return directive;
}

export type GraphQLDirectiveExtensions = ReadOnlyObjMap<mixed>;

/**
* Directives are used by the GraphQL runtime as a way of modifying execution
* behavior. Type system creators will usually not create these directly.
Expand All @@ -54,7 +52,7 @@ export class GraphQLDirective {
locations: Array<DirectiveLocationEnum>;
args: Array<GraphQLArgument>;
isRepeatable: boolean;
extensions: ?GraphQLDirectiveExtensions;
extensions: ?ReadOnlyObjMap<mixed>;
astNode: ?DirectiveDefinitionNode;

constructor(config: $ReadOnly<GraphQLDirectiveConfig>): void {
Expand Down Expand Up @@ -91,7 +89,7 @@ export class GraphQLDirective {
...GraphQLDirectiveConfig,
args: GraphQLFieldConfigArgumentMap,
isRepeatable: boolean,
extensions: ?GraphQLDirectiveExtensions,
extensions: ?ReadOnlyObjMap<mixed>,
|} {
return {
name: this.name,
Expand Down Expand Up @@ -127,7 +125,7 @@ export type GraphQLDirectiveConfig = {|
locations: Array<DirectiveLocationEnum>,
args?: ?GraphQLFieldConfigArgumentMap,
isRepeatable?: ?boolean,
extensions?: ?GraphQLDirectiveExtensions,
extensions?: ?ReadOnlyObjMapLike<mixed>,
astNode?: ?DirectiveDefinitionNode,
|};

Expand Down

0 comments on commit 2dbc5ca

Please sign in to comment.