Here is a permission check that looks responsible and quietly breaks pagination:
projects : async ( _ , { first , after }, ctx ) => { const { rows } = await ctx . db . query ( ' SELECT * FROM projects WHERE id > $1 ORDER BY id LIMIT $2 ' , [ after ?? 0 , first + 1 ], ); const visible = rows . filter (( p ) => canSee ( ctx . userId , p )); // permission check return toConnection ( visible , first ); }
Enter fullscreen mode
Exit fullscreen mode
The query fetches a page, then the resolver removes what the viewer may not see. Nothing leaks in the response. Each row is checked. Code review usually lets it through.
I measured what it does to a real user.
The setup
PostgreSQL 16, 10,000 projects. The viewer is a member of 50 of them, picked at random. The client asks for first: 20 and keeps paging while hasNextPage is true, like any Relay or Apollo client.…