Skip to content

Commit

Permalink
nested limits work with @cap-js/sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
johannes-vogel committed Feb 23, 2024
1 parent 689b0a8 commit f74062f
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 34 deletions.
64 changes: 42 additions & 22 deletions test/tests/queries/paging-offset.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,27 @@ describe('graphql - offset-based paging', () => {
}
`
const data = {
AdminServiceBasic: {
Authors: null
AdminService: {
Authors: [
{
name: 'Edgar Allen Poe',
books: [
// Edgar Allen Poe has 2 books, but only 1 requested.
{
title: 'Eleonora'
}
]
},
{
name: 'Richard Carpenter',
books: []
}
]
}
}
const errors = [
{
locations: [{ column: 13, line: 4 }],
message: 'Pagination is not supported in expand',
path: ['AdminServiceBasic', 'Authors']
}
]

const response = await POST('/graphql', { query })
expect(response.data).toEqual({ data, errors })
expect(response.data).toEqual({ data })
})
})

Expand Down Expand Up @@ -120,8 +128,7 @@ describe('graphql - offset-based paging', () => {
expect(response.data).toEqual({ data })
})

// @cap-js/sqlite does not throw that error
test.skip('query with top and skip arguments on nested fields', async () => {
test('query with top and skip arguments on nested fields', async () => {
const query = gql`
{
AdminService {
Expand All @@ -140,19 +147,32 @@ describe('graphql - offset-based paging', () => {
`
const data = {
AdminService: {
Authors: null
Authors: {
nodes: [
{
name: 'Edgar Allen Poe',
books: {
// Edgar Allen Poe has 2 books, but only 1 requested.
nodes: [
{
title: 'Eleonora'
}
]
}
},
{
name: 'Richard Carpenter',
books: {
nodes: []
}
}
]
}
}
}
const errors = [
{
locations: [{ column: 13, line: 4 }],
message: 'Pagination is not supported in expand',
path: ['AdminService', 'Authors'],
extensions: expect.any(Object)
}
]

const response = await POST('/graphql', { query })
expect(response.data).toEqual({ data, errors })
expect(response.data).toEqual({ data })
})
})
})
38 changes: 26 additions & 12 deletions test/tests/queries/totalCount.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ describe('graphql - queries with totalCount', () => {
expect(response.data).toEqual({ data })
})

// @cap-js/sqlite does not throw that error
test.skip('query with totalCount and top and skip arguments on nested fields', async () => {
test('query with totalCount and top and skip arguments on nested fields', async () => {
const query = gql`
{
AdminService {
Expand All @@ -161,19 +160,34 @@ describe('graphql - queries with totalCount', () => {
`
const data = {
AdminService: {
Authors: null
Authors: {
totalCount: 4,
nodes: [
{
name: 'Edgar Allen Poe',
books: {
totalCount: null, // REVISIT: expected 2
nodes: [
{
title: 'Eleonora'
}
]
}
},
{
name: 'Richard Carpenter',
books: {
totalCount: null, // REVISIT: expected 0
nodes: []
}
}
]
}
}
}
const errors = [
{
locations: [{ column: 11, line: 4 }],
message: 'Pagination is not supported in expand',
path: ['AdminService', 'Authors'],
extensions: expect.any(Object)
}
]

const response = await POST('/graphql', { query })
expect(response.data).toEqual({ data, errors })
expect(response.data).toEqual({ data })
})

test('query with aliases on totalCount on nested fields', async () => {
Expand Down

0 comments on commit f74062f

Please sign in to comment.