Type as property resolves on prisma server but not on graphl-yoga


#1

I’m using a prisma server and graphql-yoga server and I’m working for the first time with a type that has an other type as property. It’s one way so no relation I believe. In my case, a Product can be in a FavoriteList (so belong?) but a FavoriteList doesn’t have a relation the other way around.

type Product {
  id: ID!
  name: String!
  releaseDate: DateTime!
  brand: Brand!
  createdAt: DateTime!
  image: Image!
  barcode: String
}

type FavoriteList {
  id: ID!
  products: [Product]
}

On my prisma admin I can add a record to FavoriteList with connecting [Product] and in the playground I can query for that by using the FavoriteLists query. But when I create a query (and resolver) for my graphql-yoga server products are resolving as null. The query I’m using:

# prisma server & graphql server
query favoriteList {
  favoriteLists {
    id
    products {
      id
      name
    }
  }
}

My setup for the graphql-server

type Query {
  // ... other queries
  favoriteLists: [FavoriteList]
}

// resovler in Query.js
async favoriteLists(root, args, context, info) {
  return context.prisma.favoriteLists({}, info)
},

So having the same query, I am wondering if I have to do something else in my graphql-server? From what I can see the Product is not resolving on the FavoriteList type. Thanks in advance.


#2

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.