<@U0RQY0KK5> I’m getting `Error: Cannot return nul...
# orm-help
w
@nilan I’m getting
Error: Cannot return null for non-nullable field CartItem.id.
for a simple mutation - I’ve found a few older threads about this but I wanted to see if you had ideas on what this might be
n
Hey @wesbos, for some reason your resolver returns
null
but is supposed to return something non-null. Can you share your resolver implementation so we can figure out why this is?
w
Copy code
async removeFromCart(parent, args, ctx, info) {
    return ctx.db.mutation.deleteManyCartItems(
      {
        where: {
          id: args.id,
          user: {
            id: ctx.request.userId,
          },
        },
      },
      info
    );
  },
The only reason I’m using
deleteManyCartItems
here is because I want to query based on the item ID and the Users ID - so maybe that is it?
n
deleteManyCartItems
only returns the field
count
w
ohhhh
n
it doesn't return a field of type
CartItem
w
Is there another way to delete something by provding two inputs?
n
the item id is already enough, is it not?
w
well I don’t want anyone to be able to delete anything, so I rather not query the item, check the user, and then delete it
this is a bit of a shortcut to only delete it if the requested user owns that item
n
I see - you can use that logic, if you adjust your schema accordingly so it returns
count
if you want to return a
CartItem
, you cannot use this approach, or you have to query the
CartItem
before running
deleteManyCartItems
w
okay that makes sense - I’ll do two queries then
👍 2
w
Looks like half of the projects are about ecommerce stuff 😅
w
😄
n
half the world is ecommerce 😄
w
Would save a lot of time if we did a complete boilerplate 👀
🦜 1