Jim
05/04/2018, 1:02 PMlocation(parent, args, ctx, info) {
const { machineName } = args;
return ctx.db.query.locations({ where: { machineName } }, info);
}
This query from the front-end:
{
location(machineName: "london") {
id
name
}
}
Will return:
{
"data": {
"location": [
{
"id": "cjgrqosbt5eum0b51hz4yqrou",
"name": "London"
}
]
}
}
But id like something like:
{
"data": {
"location" {
"id": "cjgrqosbt5eum0b51hz4yqrou",
"name": "London"
}
}
}
harmony
05/04/2018, 1:05 PMasync location(parent, args, ctx, info) {
const { machineName } = args;
const res = await ctx.db.query.locations({ where: { machineName } }, info);
return res[0];
}
Corjen
05/04/2018, 1:15 PMctx.db.query.location({where: {machineName}}, info);
medelman
05/04/2018, 1:16 PMnilan
05/04/2018, 1:20 PMLocation
.
That you are using the locations
query (which returns a type [Location!]!
) internally is an implementation detail and shouldn't dictate your client facing API.