What could be the issue here?
# orm-help
z
What could be the issue here?
j
we’ll need more information to help you. do you have your code online somewhere?
z
No I don't. What do you need me to provide in the snippet?
j
what does your query look like? what do the resolvers look like?
are you using the playground to query or a client
?
z
Am using the playground to test the queries of my prisma server
I also use react-apollo for my client side
j
and the resolver for your users query?
z
Copy code
{
  getViewerOrganization(id: "cjuk3jlni4qxd0b363e3q34hr") {
    id
    users {
      id
    }
  }
}`
users: async (parent, args, context) => { return await context.db.users() },
Here's my resolver for the users query
j
Copy code
{
 getViewerOrganization(where: { id: “cjuk3jlni4qxd0b363e3q34hr”}) {
   id
   users {
     id
   }
 }
}`
z
try { const id = await getUserId(context); const user = await context.db.user({id}); if (!user && user.role !== 'OWNER') { return new ForbiddenError('Permission denied'); } if (args.id === null || args.id === "") { return new ForbiddenError('Missing Organization ID'); } const organization = await context.db.organization({id: args.id}); return { ...organization } } catch (e) { return new ApolloError(e.message); }
getViewerOrganization(id: ID!): Organization!
I've updated the snippet
j
you’re trying to return an organization or a user?
z
An organization has users, am trying to return the organization and it's users but users returns null yet in prisma cloud they exist
type Organization { id: ID! @unique name: String! users: [User!]! @relation(name: "OrganizationUsers") }
j
do you have a resolver for organization?
z
For organization alone? No. I am not using it.
j
const organization = await context.db.organization({id: args.id});
i think you need a resolver here
not here, but for this
unless you’re using bindings and forwarding it along, but i don’t see that
z
Am using the prisma-client which gives me organization data
Copy code
{
  "data": {
    "getViewerOrganization": {
      "id": "cjuk3jlni4qxd0b363e3q34hr",
      "users": null
    }
  }
}
It returns the organization ID and other details but doesn't return the users
j
you’re sure you’re connecting them?
z
Pardon? Connecting?
Copy code
{
  "data": {
    "organization": {
      "users": [
        {
          "id": "cjujx5zmy2yk20b36cqu0vvzp"
        }
      ]
    }
  }
}
j
hmm
z
This one i tested on the prisma cloud endpoint which brings the users. I wonder why the resolvers don't
z
I can query organization perfectly but since an organization has a list of users, the resolver that does not return the list of users in the organization it returns null, whereas on the playground, prisma return the list of users
j
i don’t quite understand the setup. if you move something up to the internet, i’d be happy to have a look.