menu

EdgeDB

Bringing state-of-the-art database technology to the masses.

Channels
Team

GraphQL lookup by ID

February 15, 2020 at 7:22pm

GraphQL lookup by ID

February 15, 2020 at 7:22pm
Bearing in mind I'm just learning GraphQL and EdgeDB...
The idiomatic GraphQL lookup query appears to be something like:
{ Product(id: "1000") { id name } }
From the "Variables" section of the EdgeDB GraphQL docs, this seems to be supported:
query ($title: String!) {
Book(title: $title) {
title
synopsis
}
}
But is it actually supported? In Graphiql I just get QueryError: Unknown argument

February 17, 2020 at 3:43pm
That documentation bit seems to be wrong. The filtering syntax is slightly different:
{
Book(filter:{id: {eq: "aad58a6c-519b-11ea-8d03-f34076b26a80" }}) {
title
}
}
  • reply
  • like
Thanks. I figured out that syntax. Are there any plans to support the more compact style? Would be nice if edge supported the more idiomatic style.
  • reply
  • like

February 18, 2020 at 5:21pm
We typically try to avoid having special cases, as they tend to restrict what can be expressed and future updates to the functionality. Having { Product(id: "1000") { id name } } would be incompatible with a hypothetical future feature like { Product(id: {in: ["1000", "2000"] } ) { id name } } due to how scalars and object types in GraphQL work. Also, creating special cases usually adds the burden of remembering what is and isn't special on the users and that tends to create more confusion.
  • reply
  • like