Graphql-engine: document the relational insert feature

Created on 4 Jan 2019  路  6Comments  路  Source: hasura/graphql-engine

Currently we just have this one example at https://docs.hasura.io/1.0/graphql/manual/mutations/insert.html#insert-an-object-and-its-nested-object-in-the-same-mutation

docs intermediate high

Most helpful comment

@lishine this is a current limitation of nested inserts for 1-1 relationships. Its being tracked at #2576.

All 6 comments

@0x777 Are you looking for more explanation or better visibility?
This is also repeated at https://docs.hasura.io/1.0/graphql/manual/mutations/multiple-mutations.html#insert-an-object-and-a-nested-object-in-the-same-mutation

Explanation, for example, what is update_columns/constraint etc. Few examples with many-to-many relationships too will help.

  • adding multiple nested objects in case of array relationships
  • passing arguments to nested insert (eg. on_conflict)

any update on this? Currently its a huge grey zone how insert/updates of relations in general works. I have a 1:1 relation of users => client setup and have a hard time to get the statement up and running.

mutation{
  insert_users(
    objects:[
      {
        email:"test"
        password:"test"
        role:"client",
        first_name:"test"
        client:{
          data:{
            placement_status_id:1
          }
        }
      }
    ]
  ){
    affected_rows
  }
}

I receive an error

{
  "errors": [
    {
      "extensions": {
        "path": "$.selectionSet.insert_users.args.objects[0]",
        "code": "constraint-violation"
      },
      "message": "Not-NULL violation. null value in column \"id\" violates not-null constraint"
    }
  ]
}

What is your id field type?

@lishine this is a current limitation of nested inserts for 1-1 relationships. Its being tracked at #2576.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

codepunkt picture codepunkt  路  3Comments

bogdansoare picture bogdansoare  路  3Comments

rikinsk-zz picture rikinsk-zz  路  3Comments

Fortidude picture Fortidude  路  3Comments

lishine picture lishine  路  3Comments