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

How to update an array of uuids? #3887

Closed
joshuarobs opened this issue Feb 14, 2020 · 1 comment
Closed

How to update an array of uuids? #3887

joshuarobs opened this issue Feb 14, 2020 · 1 comment

Comments

@joshuarobs
Copy link

joshuarobs commented Feb 14, 2020

e.g. something like this doesn't work:

mutation updateAuthors {
  update_items(where: {id: {_eq: "5210fb1e-db61-412f-bc20-e3b701c05068"}}, _set: {post_ids: "{87eadf2f-85fd-4667-968c-10d20dfdceff, 6dc8db0b-0cb8-486c-9492-24adb1430149}"}) {
    returning {
      id
      name
      post_ids {
        id
        name
      }
    }
  }
}

I get this error:

{
  "errors": [
    {
      "extensions": {
        "path": "$",
        "code": "data-exception"
      },
      "message": "invalid input syntax for type uuid: \"{87eadf2f-85fd-4667-968c-10d20dfdceff, 6dc8db0b-0cb8-486c-9492-24adb1430149}\""
    }
  ]
}

Square brackets don't seem to work either:

{
  "errors": [
    {
      "extensions": {
        "path": "$",
        "code": "data-exception"
      },
      "message": "invalid input syntax for type uuid: \"[87eadf2f-85fd-4667-968c-10d20dfdceff, 6dc8db0b-0cb8-486c-9492-24adb1430149]\""
    }
  ]
}

I'm looking to set an empty array of uuids to an array of 2 existing uuids. How can you do this in Hasura? I tried removing the {} and the " " from the code in the _set: .... part of the query, but they don't work. I don't seem to be able to get this to work with a uuid. Also I'm sure I have an array relationship set, as I can successfully query an author, if it has one post id in it.

@joshuarobs
Copy link
Author

Realised I did it all wrong and that I had to follow instructions from here to properly setup many to many relationships: https://docs.hasura.io/1.0/graphql/manual/schema/relationships/database-modelling/many-to-many.html

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

1 participant