Skip to content

Commit

Permalink
Support UUID contains filters (#1379)
Browse files Browse the repository at this point in the history
* Support UUID contains and begins_with filters

* Add rush change

* Move azure-region to East US

* Revert "Move azure-region to East US"

This reverts commit 01a0672.
  • Loading branch information
gonzalojaubert authored Apr 19, 2023
1 parent 234ace4 commit a25cf5a
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@boostercloud/framework-core",
"comment": "Support UUID contains and beginsWith filters",
"type": "patch"
}
],
"packageName": "@boostercloud/framework-core"
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ export class GraphqlQueryFilterArgumentsBuilder {
eq: { type: GraphQLID },
ne: { type: GraphQLID },
in: { type: GraphQLList(GraphQLID) },
beginsWith: { type: GraphQLString },
contains: { type: GraphQLString },
isDefined: { type: GraphQLBoolean },
}
// use `name`, `typeGroup` === 'Interface'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,54 @@ describe('Read models end-to-end tests', () => {
expect(cartData[0].payment.id).to.be.eq(mockPaymentId)
})

it('should retrieve ´a list of carts when filter by contains with UUID fields', async () => {
const partialMockCartId = mockCartId.slice(1, -1)
const filter = {
and: [
{
id: { eq: mockCartId },
},
{
id: {
contains: partialMockCartId,
},
},
],
}

const queryResult = await waitForIt(
() => {
return client.query({
variables: {
filter: filter,
},
query: gql`
query ListCartReadModels($filter: ListCartReadModelFilter) {
ListCartReadModels(filter: $filter) {
items {
id
shippingAddress {
firstName
}
}
}
}
`,
})
},
(result) => {
const carts = result?.data?.ListCartReadModels?.items
return carts?.length >= 1 && carts[0].id === mockCartId
}
)

const cartData = queryResult.data.ListCartReadModels.items

expect(cartData).to.be.an('array')
expect(cartData.length).to.equal(1)
expect(cartData[0].id).to.equal(mockCartId)
})

it('should retrieve a list of carts when filter by null', async () => {
const mockPaymentId: string = random.uuid()
await client.mutate({
Expand Down

0 comments on commit a25cf5a

Please sign in to comment.