here is how i modified my index.js to allow for cu...
# orm-help
a
here is how i modified my index.js to allow for custom resolvers
Copy code
const resolvers = {
  Query,
  Mutation,
  ItemConnection: {
    aggregate: (parent, args, context, info) => {
      return context.prisma.itemsConnection(args).aggregate();
    }
  },
  User: {
    cart(parent, args, context, info) {
      return context.prisma.user({ id: context.request.userId }).cart();
    }
  },
  CartItem: {
    item(parent, args, context, info) {
      return context.prisma.cartItem({ id: parent.id }).item();
    }
  },
  Order: {
    user(parent, args, context, info) {
      return context.prisma.order({ id: parent.id }).user();
    }
  },
  Order: {
    items(parent, args, context, info) {
      return context.prisma.order({ id: parent.id }).items();
    }
  }
};
n
you have Order twice
a
Yeah, I thought it'd make sense because i have both the user field and an items field on the Order type
what do you think?
n
I think
user
and
items
fields should be in the same
Order
object
a
@nuno
you mean this way?
Copy code
Order: {
    user(parent, args, context, info) {
      return context.prisma.order({ id: parent.id }).user();
    },
    items(parent, args, context, info) {
      return context.prisma.order({ id: parent.id }).items();
    }
  }
👍 1
thanks, a moment though
@nuno the error persists. I have orders in my database but I can't seem to query for a single order
n
did you see my reply in your other message?
a
here, but my query for a single order will return an error