here is the resolver for it ```async order(root, a...
# orm-help
a
here is the resolver for it
Copy code
async order(root, args, context, info) {
    //1. make sure they are logged in.
    if (!context.request.userId) {
      throw new Error("You must be logged in.");
    }
    //2. query the current order.
    const order = await context.prisma.order({
      id: args.id
    }).$fragment(`{
      user{
        id
      }
    }`);
    //3. check if they ahve the permissions to see this order
    const ownsOrder = order.user.id === context.request.userId;
    const hasPermissionToSeeOrder = context.request.user.permissions.includes(
      "ADMIN"
    );
    if (!ownsOrder || !hasPermissionToSeeOrder) {
      throw new Error("You don't have permissions to see this.");
    }
    //4. return the order.
    return order;
  }
n
I think the order query fragment needs to be like:
Copy code
{
      id
      charge
      total
      createdAt
      user {
        id
      }
      items {
        id
        title
        description
        price
        image
        quantity
      }
    }
At least the fields you request on the frontend
☝️
a
seen
wait
Thanks alot @nuno
it worked 🔥
j
that "cannot return null...." generally means that the error is in the resolver and the error isn't being handled properly. Use try/catch whenever accessing the api and console.log the errors. it makes life easier!
a
prisma cool