Skip to content

Commit

Permalink
chore: threads through forceNullable in buildObjectType
Browse files Browse the repository at this point in the history
  • Loading branch information
jmikrut committed Aug 4, 2022
1 parent 1e72301 commit 6167390
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/graphql/schema/buildObjectType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,36 +62,36 @@ function buildObjectType({
const fieldToSchemaMap = {
number: (objectTypeConfig: ObjectTypeConfig, field: NumberField) => ({
...objectTypeConfig,
[field.name]: { type: withNullableType(field, GraphQLFloat) },
[field.name]: { type: withNullableType(field, GraphQLFloat, forceNullable) },
}),
text: (objectTypeConfig: ObjectTypeConfig, field: TextField) => ({
...objectTypeConfig,
[field.name]: { type: withNullableType(field, GraphQLString) },
[field.name]: { type: withNullableType(field, GraphQLString, forceNullable) },
}),
email: (objectTypeConfig: ObjectTypeConfig, field: EmailField) => ({
...objectTypeConfig,
[field.name]: { type: withNullableType(field, EmailAddressResolver) },
[field.name]: { type: withNullableType(field, EmailAddressResolver, forceNullable) },
}),
textarea: (objectTypeConfig: ObjectTypeConfig, field: TextareaField) => ({
...objectTypeConfig,
[field.name]: { type: withNullableType(field, GraphQLString) },
[field.name]: { type: withNullableType(field, GraphQLString, forceNullable) },
}),
code: (objectTypeConfig: ObjectTypeConfig, field: CodeField) => ({
...objectTypeConfig,
[field.name]: { type: withNullableType(field, GraphQLString) },
[field.name]: { type: withNullableType(field, GraphQLString, forceNullable) },
}),
date: (objectTypeConfig: ObjectTypeConfig, field: DateField) => ({
...objectTypeConfig,
[field.name]: { type: withNullableType(field, DateTimeResolver) },
[field.name]: { type: withNullableType(field, DateTimeResolver, forceNullable) },
}),
point: (objectTypeConfig: ObjectTypeConfig, field: PointField) => ({
...objectTypeConfig,
[field.name]: { type: withNullableType(field, new GraphQLList(GraphQLFloat)) },
[field.name]: { type: withNullableType(field, new GraphQLList(GraphQLFloat), forceNullable) },
}),
richText: (objectTypeConfig: ObjectTypeConfig, field: RichTextField) => ({
...objectTypeConfig,
[field.name]: {
type: withNullableType(field, GraphQLJSON),
type: withNullableType(field, GraphQLJSON, forceNullable),
async resolve(parent, args, context) {
if (args.depth > 0) {
await createRichTextRelationshipPromise({
Expand Down Expand Up @@ -191,12 +191,13 @@ function buildObjectType({
name: combineParentName(parentName, field.name),
values: formatOptions(field),
}),
forceNullable,
),
},
}),
checkbox: (objectTypeConfig: ObjectTypeConfig, field: CheckboxField) => ({
...objectTypeConfig,
[field.name]: { type: withNullableType(field, GraphQLBoolean) },
[field.name]: { type: withNullableType(field, GraphQLBoolean, forceNullable) },
}),
select: (objectTypeConfig: ObjectTypeConfig, field: SelectField) => {
const fullName = combineParentName(parentName, field.name);
Expand All @@ -207,7 +208,7 @@ function buildObjectType({
});

type = field.hasMany ? new GraphQLList(type) : type;
type = withNullableType(field, type);
type = withNullableType(field, type, forceNullable);

return {
...objectTypeConfig,
Expand Down Expand Up @@ -396,7 +397,7 @@ function buildObjectType({
parentName: fullName,
forceNullable,
});
const arrayType = new GraphQLList(withNullableType(field, type));
const arrayType = new GraphQLList(withNullableType(field, type, forceNullable));

return {
...objectTypeConfig,
Expand Down

0 comments on commit 6167390

Please sign in to comment.