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

[v4] null values ignored when creating objects #584

Closed
EyMaddis opened this Issue Sep 14, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@EyMaddis

EyMaddis commented Sep 14, 2017

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.

@EyMaddis EyMaddis changed the title from [v4] unable to create objects and pass null values to [v4] null values ignored when creating objects Sep 14, 2017

@benjie

This comment has been minimized.

Show comment
Hide comment
@benjie

benjie Sep 14, 2017

Member

I guess we're doing a value check rather than a key check; though I'm not sure if the GraphQL specification actually differentiates between these two cases.

Member

benjie commented Sep 14, 2017

I guess we're doing a value check rather than a key check; though I'm not sure if the GraphQL specification actually differentiates between these two cases.

@EyMaddis

This comment has been minimized.

Show comment
Hide comment
@EyMaddis

EyMaddis commented Sep 14, 2017

@benjie it does: facebook/graphql#83

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment