Skip to content

Commit

Permalink
Remove deprecate getFieldDefFn argument of TypeInfo constructor (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov authored May 11, 2022
1 parent b4ad128 commit 75eb3eb
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions src/utilities/TypeInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export class TypeInfo {
private _directive: Maybe<GraphQLDirective>;
private _argument: Maybe<GraphQLArgument>;
private _enumValue: Maybe<GraphQLEnumValue>;
private _getFieldDef: GetFieldDefFn;

constructor(
schema: GraphQLSchema,
Expand All @@ -62,9 +61,6 @@ export class TypeInfo {
* beginning somewhere other than documents.
*/
initialType?: Maybe<GraphQLType>,

/** @deprecated will be removed in 17.0.0 */
getFieldDefFn?: GetFieldDefFn,
) {
this._schema = schema;
this._typeStack = [];
Expand All @@ -75,7 +71,6 @@ export class TypeInfo {
this._directive = null;
this._argument = null;
this._enumValue = null;
this._getFieldDef = getFieldDefFn ?? getFieldDef;
if (initialType) {
if (isInputType(initialType)) {
this._inputTypeStack.push(initialType);
Expand Down Expand Up @@ -160,7 +155,7 @@ export class TypeInfo {
let fieldDef;
let fieldType: unknown;
if (parentType) {
fieldDef = this._getFieldDef(schema, parentType, node);
fieldDef = getFieldDef(schema, parentType, node);
if (fieldDef) {
fieldType = fieldDef.type;
}
Expand Down Expand Up @@ -291,37 +286,34 @@ export class TypeInfo {
}
}

type GetFieldDefFn = (
schema: GraphQLSchema,
parentType: GraphQLType,
fieldNode: FieldNode,
) => Maybe<GraphQLField<unknown, unknown>>;

/**
* Not exactly the same as the executor's definition of getFieldDef, in this
* statically evaluated environment we do not always have an Object type,
* and need to handle Interface and Union types.
*/
function getFieldDef(
schema: GraphQLSchema,
parentType: GraphQLType,
parentType: GraphQLCompositeType,
fieldNode: FieldNode,
): Maybe<GraphQLField<unknown, unknown>> {
const name = fieldNode.name.value;
const fieldName = fieldNode.name.value;
if (
name === SchemaMetaFieldDef.name &&
fieldName === SchemaMetaFieldDef.name &&
schema.getQueryType() === parentType
) {
return SchemaMetaFieldDef;
}
if (name === TypeMetaFieldDef.name && schema.getQueryType() === parentType) {
if (
fieldName === TypeMetaFieldDef.name &&
schema.getQueryType() === parentType
) {
return TypeMetaFieldDef;
}
if (name === TypeNameMetaFieldDef.name && isCompositeType(parentType)) {
if (fieldName === TypeNameMetaFieldDef.name && isCompositeType(parentType)) {
return TypeNameMetaFieldDef;
}
if (isObjectType(parentType) || isInterfaceType(parentType)) {
return parentType.getFields()[name];
return parentType.getFields()[fieldName];
}
}

Expand Down

0 comments on commit 75eb3eb

Please sign in to comment.