Skip to content

Commit

Permalink
Add enrich test with input object containing literal value on scalar …
Browse files Browse the repository at this point in the history
…field
  • Loading branch information
schwma committed Mar 4, 2024
1 parent 9ed44e0 commit 00efacd
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion test/tests/enrich.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ describe('graphql - enrich AST ', () => {
expect(value).toEqual(2)
})

test('parsing of literal value in nested input value', async () => {
test('parsing of literal value in nested input value of a query with sub-selection of fields', async () => {
const query = gql`
{
AdminService {
Expand All @@ -198,6 +198,25 @@ describe('graphql - enrich AST ', () => {
const value = enrichedAST[0].selectionSet.selections[0].arguments[0].value.fields[0].value.fields[0].value.value
expect(value).toEqual(201)
})

test('parsing of literal value in nested input value of a mutation with a scalar return type', async () => {
const query = gql`
mutation {
AdminService {
Authors {
delete(filter: { dateOfBirth: { eq: "1818-07-30T00:00:00.000Z" } })
}
}
}
`
const document = parse(query)
const fakeInfo = fakeInfoObject(document, bookshopSchema, 'Mutation')
const enrichedAST = enrich(fakeInfo)
const value =
enrichedAST[0].selectionSet.selections[0].selectionSet.selections[0].arguments[0].value.fields[0].value
.fields[0].value.value
expect(value).toEqual('1818-07-30')
})
})

describe('variable values are substituted into the AST', () => {
Expand Down

0 comments on commit 00efacd

Please sign in to comment.