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

Support mutations by global ID #126

Closed
ivosabev opened this issue Sep 22, 2016 · 4 comments
Closed

Support mutations by global ID #126

ivosabev opened this issue Sep 22, 2016 · 4 comments

Comments

@ivosabev
Copy link

I think postgrahql should support the global id in mutations, since in Relay this is the primary source of identifying an object and here rowId is only provided as a convenience.

mutation updateTeam($input: UpdateTeamInput!) {
  updateTeam(input: $input) {
    team {
      id,
      name
    }
  }
}

{
  "input": {
    "id":"dGVhbTox",
    "newName": "My Team"
  }
}
@calebmer
Copy link
Collaborator

Yep, this is definitely something that will be in PostGraphQL 2 😊. Also being able to insert/update/delete by any unique constraint as well similar to how you can select by any unique constraint.

The one difficulty around this is how do we support procedures? For mutations I’m fine with an updateTeam, updateTeamByRowId, updateTeamByUniqueColumn etc. However, for procedures that take a row as an argument do we make extra copies of that as well? To illustrate the problem, say we have a procedure and it’s a mutation:

create function do_stuff(person person, i integer) returns person …

What would our GraphQL mutations look like?

type Mutation {
  doStuff(personId: ID, i: Int): DoStuffPayload
  doStuffByRowId(personRowId: ID, i: Int): DoStuffPayload
  doStuffByEmail(personEmail: Email, i: Int): DoStuffPayload
}

…or do we only have a mutation using the global id?

@calebmer
Copy link
Collaborator

I also want to say thanks, keep opening issues questioning assumptions made in PostGraphQL 1. We’ve learned a lot and while I don’t want to make too many breaking changes in 2, I think it gives us a great chance to question our assumptions and make a better API 👍

I’ll be opening an issue soon with some of the breaking changes I want to make and we can discuss them individually. There won’t be many and there will be backwards compatibility options for most of them 👍

@ivosabev
Copy link
Author

ivosabev commented Sep 22, 2016

I think mutations should be only by global id and the rowId should not be given any primary key status, but be treated as a simple database column.

The only update mutation would be:

mutation updateStuff($input: UpdateStuffPayload!) {
  updateStuff(input: $input) {
    id,
    rowId,
    email 
  }
}

{
  "input": {
     "id": "Xja1j=",
     "email": "new@email.com"
  }
}

I am not sure I understand your concern with the procedures?

@calebmer calebmer mentioned this issue Oct 10, 2016
4 tasks
@calebmer calebmer added this to the 2.0.0 milestone Oct 13, 2016
@calebmer
Copy link
Collaborator

I’m going to close this as its in the PostGraphQL 2.0 beta 🎉

Start playing with the pre-release, the final release should be out really soon. Tell me what you think! 👍

npm install -g postgraphql@next
postgraphql

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

No branches or pull requests

3 participants