Skip to content

[v4] null values ignored when creating objects #584

@EyMaddis

Description

@EyMaddis

Hi,
it is impossible to use null values when creating new objects, as it will be filtered out in the SQL insert.

I already created a breaking test PR in graphile-build.

mutation insertMyType {
    createMyType(input: {
        myType: {
            id: "a fix id",
            nullableField: null
        }
    })  {
        myType {
            nullableField // => returns the default value from the database instead of "null"
        }
    }
}

will result in something like this (adapted by hand, maybe not perfect):

select set_config($1, $2, true), set_config($3, $4, true), set_config($5, $6, true), set_config($7, $8, true), set_config($9, $10, true)
with __local_0__ as (
    insert into "public"."my_type" (
        "id"
    ) values($1) returning *
)
select __local_0__::"public"."my_type" from __local_0__

Note the absence of "nullable_field".

This introduced a breaking change when switching from v3 to v4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions