-
Notifications
You must be signed in to change notification settings - Fork 54
help with the resolving connections #337
Comments
I have a similar problem with subscriptions right now. |
it seems that it works similar as the other resolvers with small difference, |
I have same problem.. when I generate types I am missing
|
My workaround. Query resolver
Child resolver
|
@khayong |
My mistake, Flow does prompt missing property 'aggregate' from parent object. |
I was just worked around the Typescript compiler error by using the bracket notation instead of dot notation property accessor: export const connectionResolvers: UserConnectionResolvers.Type = {
...UserConnectionResolvers.defaultResolvers,
aggregate(parent) {
return parent["aggregate"];
}
}; That said, I have to imagine there's a way of doing this that doesn't resort to tricking the compiler. Would love to hear of a better solution if anyone knows. |
@dddicillo @khayong models:
files:
- ./.../types.ts
- ./.../generated/prisma-client/index.ts and use connection definition like this export interface DepartmentConnection {
params: IDepartmentConnectionParams,
pageInfo: prisma.PageInfo,
edges: prisma.DepartmentEdge[]
}; than solve the problem P.S. My params interface is the same type that I pass into |
that seems like an unnecessary hack for a feature that should work. |
and why none of the members of the team gives no info or guideline on how to use connections? they must have tested it and made it work |
Hey there, The reason why there aren't guidelines at the moment on how to use connections is because we haven't yet fully solved the problem with connections in the "schema-first" world. The best answer I can give you for now is to follow @khayong's solution. We might decide to always include Here are the steps: 1/ // ./src/types.ts
import { UserEdge, PageInfo, AggregateUser } from '../prisma-client'
type UserConnection {
edges: UserEdge[]
pageInfo: PageInfo
aggregate: AggregateUser
} // graphqlgen.yml
models:
files:
# Make sure put this file BEFORE the prisma-client so that it takes the right `UserConnection` type
- ./src/types.ts
- ./src/generated/prisma-client 2/ Do the following in your const Query: QueryResolvers = {
usersConnection: async (parent, args, ctx) => {
const { edges, pageInfo } = await ctx.prisma.usersConnection(args);
const aggregate = await ctx.prisma.usersConnection(args).aggregate();
return {
edges,
pageInfo,
aggregate
};
}
} Hopefully that was helpful 🙌 |
Hello I have issue in nodeJS timeseries query.
Node js Code: when I use raw query in druid end point it is working fine in postman.
Please help me to fix issue |
hi, I've followed the examples and managed to get the most of the stuff working, but not the connections. How do you resolve edges, nodes, pageInfo and aggregate?
thanks for the help. ps i've reached out via slack without much help. :(
The text was updated successfully, but these errors were encountered: