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

[v4] null values ignored when creating objects #584

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

[v4] null values ignored when creating objects #584

EyMaddis opened this issue Sep 14, 2017 · 2 comments

Comments

@EyMaddis
Copy link
Contributor

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 [v4] unable to create objects and pass null values [v4] null values ignored when creating objects Sep 14, 2017
@benjie
Copy link
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
Copy link
Contributor Author

@benjie it does: graphql/graphql-spec#83

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants