Hi, Is there a way to query contacted fields? Say...
# orm-help
r
Hi, Is there a way to query contacted fields? Say i have firstName and lastName fields in the type and i want to query like {firstName+lastName}_contains. What is the best way to accomplish that?
h
You can use fragments
Copy code
fullLink: {
    fragment: `fragment FullLink on Url { id }`,
    resolve: async ({ id }, args, ctx: Context, info) => {
      const url = await ctx.db.query.url({ where: { id } })
      const fullLink = `${url.parentLink ? '/' + url.parentLink : ''}/${url.link}/`
      return fullLink.replace('\/\/', '\/')
    }
  }
for example
s
How about just using OR filter in your query
r
Thanks @huv1k for the reply I have looked into fragments and as i understand, it builds up a type object reflecting the related types as nested objects to the main type (hope i am not mistaking). Than i can query nested fields but not combine 2 fields against 1 search value. My type for example : type User { id: ID! @unique firstName: String lastName: String mobilePhone: String roleTitle: String } and i want to query “John Doe” against the combination of firstName and lastName. correct me if i am wrong please
Thanks @Stefano T I have tried using the OR, The problem is that the value “Jhon D” for example will not be populated in each of the fields (firstName and last Name), It will only be populated in the combination of both
h
You can do that in application server resolvers
r
Ok, Thanks @huv1k, i wanted to avoid resolvers at this time of development 🙂 I am using the Prisma service only as Api and wanted to keep all logic in my backend. I will look into that 👍
h
If you just delegate everything to prisma that is not possible i think i asked about it before