I'm using a Hasura Graphql api on my postgres databse.
I want to get a single row from a table using the primary key but it seems like there are 2 ways of doing this with Hasura, and I'm trying to decide which way I want to do it.
Are there any differences I should be aware of between the following two methods ?
query {
authors_by_pk(id: 1) {
id
name
}
}
query {
authors(where: {id: {_eq: 1}}) {
id
name
}
}
author_by_pksince it can only ever return 0 or 1 authorsid. However it is more flexible in that it could return many [0:N] authors if given a broaderwherequery.In practice with GraphQL one often ends up creating both queries that return singletons as well as queries that return arrays.