Skip to content
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

Narrow the return type of astFromValue #3864

Merged
merged 1 commit into from
Mar 20, 2023
Merged
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
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