Adding nodes to query connection type #521
Answered
by
hayes
BengtHagemeister
asked this question in
Q&A
-
Hi, is there a possibility to get nodes exposed on the connection type? Something like this but then automatic and including pagination: builder.queryField('posts', (t) =>
t.prismaConnection(
{
type: 'Post',
cursor: 'id',
resolve: async (query) =>
db.posts.findMany({
...query,
}),
},
{
fields: (t) => ({
nodes: t.prismaField({
type: ['Post'],
resolve: async (query) =>
db.posts.findMany({
...query,
}),
}),
}),
}
)
); Following a similar approach as Shopify for example (https://shopify.dev/api/admin-graphql/2022-07/queries/orders#examples-Get_the_first_10_orders). |
Beta Was this translation helpful? Give feedback.
Answered by
hayes
Aug 11, 2022
Replies: 1 comment 4 replies
-
I think you should be able to do nodes: t.field({ type: Post, resolve: (connection) => connection.edges.map(edge => edge.node) }) |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
BengtHagemeister
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think you should be able to do nodes: t.field({ type: Post, resolve: (connection) => connection.edges.map(edge => edge.node) })