palixir / wabe

Your backend in minutes not days for Node.js / Bun
https://wabe.dev
Apache License 2.0
141 stars 8 forks source link

Create util to add `isRoot: true` to a context #78

Open coratgerl opened 1 month ago

coratgerl commented 1 month ago

Is your feature request related to a problem? Please describe.

We need to add an util that take in param a WabeContext and return the same context with isRoot: true for root queries. This will avoid this very common pattern

 const user = await context.wabe.controllers.database.getObjects({
    className: 'User',
    where: {
      email: {
        equalTo: input.email,
      },
    },
    fields: ['id'],
    first: 1,
    context: {
      ...context,
      isRoot: true,
    },
  })

Additional context

Need to replace all occurence of the above pattern with the new utils. Something like that: context: contextWithRoot(context)