bifrost
bifrost copied to clipboard
Use unique IDs and allow partial matches when querying for names
I guess the main identifier for substances is its name.
Should we have an additional nonmutable id
field for Substance
and maybe Effect
?
Let's say we start using the names as the single source of truth for querying a substance. I'm not sure if this is a realistic scenario, but what if the name of a substance changes for some reason. The original query would be affected. This could lead to 404 errors, for instance.
It would also be nice to query for substances using its ID for a more assertive query. Right now, we use:
Query.substances
query {
substances(query: "LSD") {
name
}
}
{
"data": {
"substances": [
{
"name": "LSD"
}
]
}
}
The response is an array, which suggests that we could have more than 1 result. This could be helpful for search boxes, like starting to type "25" and already get a list of the 25-NB family.
But still, I couldn't query a list of more than 1 result when searching for a partial name like "25" or "L", which I assume means that the query is searching for exact matches.
On the other hand, querying for an ID or slug could be useful for loading specific pages while being sure that they won't change. In this case, the result would be a single substance:
Query.substance
query {
substance(id: "cj9mupzg00lz10155s9npo5n2") {
name
}
}
{
"data": {
"substance": {
"name": "1P-LSD"
}
}
}