Skip to content

Commit

Permalink
Narrow the return type of astFromValue
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanowen committed Mar 16, 2023
1 parent e171a14 commit 0375b8c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/utilities/astFromValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { isIterableObject } from '../jsutils/isIterableObject.js';
import { isObjectLike } from '../jsutils/isObjectLike.js';
import type { Maybe } from '../jsutils/Maybe.js';

import type { ObjectFieldNode, ValueNode } from '../language/ast.js';
import type { ConstObjectFieldNode, ConstValueNode } from '../language/ast.js';
import { Kind } from '../language/kinds.js';

import type { GraphQLInputType } from '../type/definition.js';
Expand Down Expand Up @@ -41,7 +41,7 @@ import { GraphQLID } from '../type/scalars.js';
export function astFromValue(
value: unknown,
type: GraphQLInputType,
): Maybe<ValueNode> {
): Maybe<ConstValueNode> {
if (isNonNullType(type)) {
const astValue = astFromValue(value, type.ofType);
if (astValue?.kind === Kind.NULL) {
Expand Down Expand Up @@ -83,7 +83,7 @@ export function astFromValue(
if (!isObjectLike(value)) {
return null;
}
const fieldNodes: Array<ObjectFieldNode> = [];
const fieldNodes: Array<ConstObjectFieldNode> = [];
for (const field of Object.values(type.getFields())) {
const fieldValue = astFromValue(value[field.name], field.type);
if (fieldValue) {
Expand Down

0 comments on commit 0375b8c

Please sign in to comment.