Accessing N+1 list of data simultaneously?

prisma

#1

Using GraphQL’s connection / Complete Connection Model for additional capabilities implementing pagination causes a problem.

Query data:

export const QueryReview = gql`
    query Review($id: ID, $after: String) {
        review(id: $id) {
            ...
            commentsConnection(first: 9, after: $after) {
                aggregate {
                    count
                }
                edges {
                    node {
                        ...
                    }
                    cursor
                }
                pageInfo {
                    endCursor
                    hasNextPage
                }
            }
        }
    }
`

Query props:

export const QueryReviewProps = {
    props: (
        { data: { error, loading, review, fetchMore },
        data: { review: { commentsConnection: { edges, aggregate, pageInfo } } } }
    ) => {
        return {
            loading,
            error,
            comments: edges ? edges.node : null
        }
    }
}

Resolver:

const Review = {
    commentsConnection: {
        resolve(parent, args, {
            prisma
        }, info) {
            
            const opArgs = {
                first: args.first,
                skip: args.skip,
                after: args.after
            }
            
            return prisma.query.commentsConnection(opArgs, info)
        }
    }
}

I need to be able to refer properties of commentsConnection or the selection itself involving future implementations. However commentsConnection is a second query as a child selection of review, which then results in commentsConnection being undefined.

I confirmed the data is valid, however I cannot access both query information simultaneously. Use prisma already has a similar pattern from data-loader, so I don’t typically need to worry about batch requests.


#2

@BaoPham92

Can you please file a feature request regarding this?

Maybe this is something we can implement which our new client: https://github.com/prisma/rfcs/blob/new-ts-client-rfc/text/0000-new-ts-client.md