I am trying to implement a connection resolver for...
# orm-help
a
I am trying to implement a connection resolver for a type that I have and I'm using apollo-server (not that I think that matters). For some reason, this just returns a "cannot return null for non-null field" error:
Copy code
async personConnection(parent, args, context, info) {
    return await prisma.personsConnection()
  }
However, when I add the properties one by one:
Copy code
const aggregate = await prisma.personsConnection().aggregate()
...
return { aggregate, pageInfo, edges }
This works
Any clue? Seems like a bug in prisma 😮
y
I got the same error, I implemented the aggression by myself with raw sql request
a
Shouldn't be this way. I'm trying to update prisma and see if that solves anything
If that doesn't work, i'll file a bug
w
If you take a look at the return type of
personsConnection
, you’ll see that
aggregate
isn’t part of the response. The reason why it’s not there is because it might be costy to make the
count
, so you have to do it yourself manually!
a
It is in the client that I get generated:
Copy code
export interface PersonConnectionPromise
  extends Promise<PersonConnection>,
    Fragmentable {
  pageInfo: <T = PageInfoPromise>() => T;
  edges: <T = FragmentableArray<PersonEdge>>() => T;
  aggregate: <T = AggregatePersonPromise>() => T;
}
Yes it is a promise, but both `aggregate`and
pageInfo
are part of the shape.
w
The result of
personsConnection
is not in
PersonConnectionPromise
, but in the extended
PersonConnection
interface. What you see here are the methods available for
prisma.personsConnections().something()