Skip to content

Commit

Permalink
test: null AST convenience value in lists and filter operator conju…
Browse files Browse the repository at this point in the history
…nction (#143)

* Add test for null convenience value in lists

* Add test for filter operator conjunction

* Add changelog entry for parsing of null values in lists fix
  • Loading branch information
schwma authored Jan 5, 2024
1 parent c92fa15 commit 43cf8ca
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Name clashes when CDS elements are named `nodes` or `totalCount`
- Parsing of `null` values in lists

### Removed

Expand Down
18 changes: 18 additions & 0 deletions test/tests/enrich.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,5 +302,23 @@ describe('graphql - enrich AST ', () => {
const value = enrichedAST[0].selectionSet.selections[0].arguments[0].value.fields[0].value.fields[0].value.value
expect(value).toEqual(null)
})

test('null value passed as nested input value within a list has a value of null', async () => {
const query = gql`
{
AdminService {
Books(filter: { ID: { ne: [1, null, 3] } }) {
totalCount
}
}
}
`
const document = parse(query)
const fakeInfo = fakeInfoObject(document, bookshopSchema, 'Query')
const enrichedAST = enrich(fakeInfo)
const value =
enrichedAST[0].selectionSet.selections[0].arguments[0].value.fields[0].value.fields[0].value.values[1].value
expect(value).toEqual(null)
})
})
})
27 changes: 27 additions & 0 deletions test/tests/queries/filter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,33 @@ describe('graphql - filter', () => {
expect(response.data).toEqual({ data })
})

test('query with filter operator conjunction', async () => {
const query = gql`
{
AdminService {
Books(filter: { ID: { ne: [201, 207, 251] } }) {
nodes {
ID
title
}
}
}
}
`
const data = {
AdminService: {
Books: {
nodes: [
{ ID: 252, title: 'Eleonora' },
{ ID: 271, title: 'Catweazle' }
]
}
}
}
const response = await POST('/graphql', { query })
expect(response.data).toEqual({ data })
})

test('query with simple filter wrapped as lists', async () => {
const query = gql`
{
Expand Down

0 comments on commit 43cf8ca

Please sign in to comment.