How can I call context explicitly but have the con...
# orm-help
d
How can I call context explicitly but have the consumer dictate the selection? I.E. Query from the user
Copy code
mutation{
  createTeam(data:{
    name:"hi",
  }){
    id
    name
    createdBy{
      email
    }
  }
}
prisma-binding call
Copy code
return context.db.mutation.createTeam({
  data: {
    name: args.data.name,
    organization: {
      connect: {
        id: context.organizationId
      }
    },
    createdBy: {
      connect: {
        id: context.userId
      }
    }
  }
}, info)
I could use
Copy code
context.db.mutation.createTeam({data: {...}}, `{id, name, createdBy{ email }}`)
But I don't know what fields will be used in the selection
d
Info object maps user query fields to remote schema. Are you trying to do something else?
d
Thanks for the reply @divyendu. The reason is because I'm adding additional fields to the users original query. I.E. I'm adding the organization and createdBy
I ended up parsing the AST in the info parameter to generate
{id, name, createdBy{ email }}
depending on the needed selection
m
Hey 👋 have you heard of
fragments
? I think this could solve your problem from my understanding of your issue. Check this out https://www.prisma.io/forum/t/append-to-info-to-get-additional-fields-back/3972/2
🙌 1