Skip to content

row id vs global id #468

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

Closed
bochuxt opened this issue May 8, 2017 · 2 comments
Closed

row id vs global id #468

bochuxt opened this issue May 8, 2017 · 2 comments

Comments

@bochuxt
Copy link

bochuxt commented May 8, 2017

When query all-objects, it overrides the row id which is primary key by global id (ID!) which is a cursor.

But we still need the raw id which is table primary key.

allAuthUsers{
edges
{
node{
id
username
}
}
}


"data": {
"allAuthUsers": {
"edges": [
{
"node": {
"id": "QXV0aFVzZXI6MQ==",
"username": "anonymous"
}
},

@bochuxt
Copy link
Author

bochuxt commented May 8, 2017

class Coworker(SQLAlchemyObjectType):

class Meta:
    model = CoworkerModel
    interfaces = (relay.Node,)
rowid=graphene.Int()
@resolve_only_args
def resolve_rowid(self, **args):
    # print(self.__dict__)
    id = self.__dict__['id']
    return id

@syrusakbary
Copy link
Member

syrusakbary commented Jun 6, 2017

A similar solution to what @bochuxt pointed would be:

class Coworker(SQLAlchemyObjectType):
    class Meta:
        model = CoworkerModel
        interfaces = (relay.Node,)

    rowid=graphene.Int()

    @resolve_only_args
    def resolve_rowid(self):
        return self.id

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