Skip to content

How to change default primary ke 'id' to a custom keyname? #4073

Answered by rushairer
rushairer asked this question in General
Discussion options

You must be logged in to vote

@ardatan
Thank you again.

For Example:

type A {
id: String // This field is not unique
bundleId: String // This field is unique
}

When I got an array data of A from api request like:
[
{id: "123", bundleId: "com.abc"},
{id: "123", bundleId: "com.abcdefghijklmn"},
]
'@apollo/client' will get me an array in javascript like
[
{id: "123", bundleId: "com.abc"},
{id: "123", bundleId: "com.abc"},
]

If i change name id to anther, it will be OK, I got
[
{theId: "123", bundleId: "com.abc"},
{theId: "123", bundleId: "com.abcdefghijklmn"},
]

If I don't want to rename id field, How can I tell '@apollo/client' set bundleId to primary key, inside of 'id'

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@ardatan
Comment options

Comment options

You must be logged in to vote
2 replies
@alexlag
Comment options

@rushairer
Comment options

Answer selected by ardatan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants