Skip to content

Commit

Permalink
don't make things protected unnecessarily
Browse files Browse the repository at this point in the history
  • Loading branch information
yaacovCR committed Jun 17, 2021
1 parent e580f62 commit 602942f
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions src/execution/execute.ts
Expand Up @@ -315,25 +315,26 @@ export function buildExecutionContext(
* @internal
*/
export class Executor {
protected _exeContext: ExecutionContext;
/**
* A memoized collection of relevant subfields with regard to the return
* type. Memoizing ensures the subfields are not repeatedly calculated, which
* saves overhead when resolving lists of values.
*/
protected collectSubfields = memoize2(
collectSubfields = memoize2(
(returnType: GraphQLObjectType, fieldNodes: ReadonlyArray<FieldNode>) =>
this._collectSubfields(returnType, fieldNodes),
);

protected _exeContext: ExecutionContext;

constructor(exeContext: ExecutionContext) {
this._exeContext = exeContext;
}

/**
* Implements the "Executing operations" section of the spec.
*/
public executeOperation(): PromiseOrValue<ObjMap<unknown> | null> {
executeOperation(): PromiseOrValue<ObjMap<unknown> | null> {
const { schema, fragments, rootValue, operation, variableValues, errors } =
this._exeContext;
const type = getOperationRootType(schema, operation);
Expand Down Expand Up @@ -374,7 +375,7 @@ export class Executor {
* Given a completed execution context and data, build the { errors, data }
* response defined by the "Response" section of the GraphQL specification.
*/
public buildResponse(
buildResponse(
data: PromiseOrValue<ObjMap<unknown> | null>,
): PromiseOrValue<ExecutionResult> {
if (isPromise(data)) {
Expand All @@ -388,7 +389,7 @@ export class Executor {
* Implements the "Executing selection sets" section of the spec
* for fields that must be executed serially.
*/
protected executeFieldsSerially(
executeFieldsSerially(
parentType: GraphQLObjectType,
sourceValue: unknown,
path: Path | undefined,
Expand Down Expand Up @@ -424,7 +425,7 @@ export class Executor {
* Implements the "Executing selection sets" section of the spec
* for fields that may be executed in parallel.
*/
protected executeFields(
executeFields(
parentType: GraphQLObjectType,
sourceValue: unknown,
path: Path | undefined,
Expand Down Expand Up @@ -467,7 +468,7 @@ export class Executor {
* calling its resolve function, then calls completeValue to complete promises,
* serialize scalars, or execute the sub-selection-set for objects.
*/
protected executeField(
executeField(
parentType: GraphQLObjectType,
source: unknown,
fieldNodes: ReadonlyArray<FieldNode>,
Expand Down Expand Up @@ -531,7 +532,7 @@ export class Executor {
/**
* @internal
*/
protected buildResolveInfo(
buildResolveInfo(
fieldDef: GraphQLField<unknown, unknown>,
fieldNodes: ReadonlyArray<FieldNode>,
parentType: GraphQLObjectType,
Expand All @@ -556,10 +557,7 @@ export class Executor {
};
}

protected handleFieldError(
error: GraphQLError,
returnType: GraphQLOutputType,
): null {
handleFieldError(error: GraphQLError, returnType: GraphQLOutputType): null {
// If the field type is non-nullable, then it is resolved without any
// protection from errors, however it still properly locates the error.
if (isNonNullType(returnType)) {
Expand Down Expand Up @@ -593,7 +591,7 @@ export class Executor {
* Otherwise, the field type expects a sub-selection set, and will complete the
* value by executing all sub-selections.
*/
protected completeValue(
completeValue(
returnType: GraphQLOutputType,
fieldNodes: ReadonlyArray<FieldNode>,
info: GraphQLResolveInfo,
Expand Down Expand Up @@ -674,7 +672,7 @@ export class Executor {
* Complete a list value by completing each item in the list with the
* inner type
*/
protected completeListValue(
completeListValue(
returnType: GraphQLList<GraphQLOutputType>,
fieldNodes: ReadonlyArray<FieldNode>,
info: GraphQLResolveInfo,
Expand Down Expand Up @@ -738,10 +736,7 @@ export class Executor {
* Complete a Scalar or Enum by serializing to a valid value, returning
* null if serialization is not possible.
*/
protected completeLeafValue(
returnType: GraphQLLeafType,
result: unknown,
): unknown {
completeLeafValue(returnType: GraphQLLeafType, result: unknown): unknown {
const serializedResult = returnType.serialize(result);
if (serializedResult === undefined) {
throw new Error(
Expand All @@ -756,7 +751,7 @@ export class Executor {
* Complete a value of an abstract type by determining the runtime object type
* of that value, then complete the value for that type.
*/
protected completeAbstractValue(
completeAbstractValue(
returnType: GraphQLAbstractType,
fieldNodes: ReadonlyArray<FieldNode>,
info: GraphQLResolveInfo,
Expand Down Expand Up @@ -801,7 +796,7 @@ export class Executor {
);
}

protected ensureValidRuntimeType(
ensureValidRuntimeType(
runtimeTypeName: unknown,
returnType: GraphQLAbstractType,
fieldNodes: ReadonlyArray<FieldNode>,
Expand Down Expand Up @@ -859,7 +854,7 @@ export class Executor {
/**
* Complete an Object value by executing all sub-selections.
*/
protected completeObjectValue(
completeObjectValue(
returnType: GraphQLObjectType,
fieldNodes: ReadonlyArray<FieldNode>,
info: GraphQLResolveInfo,
Expand Down

0 comments on commit 602942f

Please sign in to comment.