Loic
07/18/2018, 6:41 AMuniqueId
in my data model but I’d like it to be id
in my schema. I feel like the solution is easy but I can’t crack it! Thanks!Jenkins
07/18/2018, 7:04 AMconst user = async (root, { userId }, { db }, info) => {
const { uniqueId: id, ...rest } = await db.query.user(
{
where: {
uniqueId: userId,
},
},
info,
);
return {
id,
...rest,
};
};
should maybe work?
I'd still suggest sticking to the same naming-convention. For simplicity. This is not as easy when querying multiple of them.Loic
07/18/2018, 7:12 AMuniqueId
wouldn’t exist since it would not be in the user query (the schema has id
and not uniqueId
).Jenkins
07/18/2018, 7:15 AMLoic
07/18/2018, 7:16 AMJenkins
07/18/2018, 7:17 AMLoic
07/18/2018, 7:20 AMconst challenge = await ctx.db.query.challenge({ where: { uniqueId: args.id } }, info);
const { uniqueId: id } = await ctx.db.query.challenge(
{ where: { uniqueId: args.id } },
`{uniqueId}`
);
return {
...challenge,
id,
};
works but I wish I didn’t have to make two callsJenkins
07/18/2018, 7:57 AMconst challenge = await ctx.db.query.challenge({ where: { uniqueId: args.id } }, info);
return {
...challenge,
id: args.id,
};
nilan
07/18/2018, 9:32 AMuniqueId
- add id
to fragments
- in field resolver, return parent.id
.
https://github.com/prismagraphql/prisma-binding/issues/194#issuecomment-402656939Loic
07/18/2018, 9:46 AMfragments
path earlier today without success, I will dig deeper and look at the github comment you shared! Thanks a lot for your help!