diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7039ea3..6a86969 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ on: jobs: test: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 @@ -20,7 +20,7 @@ jobs: publish-npm: needs: test - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4169a64..cc5be4f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,7 @@ name: Run Tests on: [push] jobs: test: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 diff --git a/API_DOCS.md b/API_DOCS.md index cb0b5cb..03d5a4f 100644 --- a/API_DOCS.md +++ b/API_DOCS.md @@ -188,7 +188,7 @@ Describes the shape and behaviour of the resources object you will pass to `getL | `isBatchKeyASet` | (Optional) Set to true if the interface of the resource takes the batch key as a set (rather than an array). For example, when using a generated clientlib based on swagger where `uniqueItems: true` is set for the batchKey parameter. Default: false. | | `propertyBatchKey` | (Optional) The argument to the resource that represents the optional properties we want to fetch. (e.g. usually 'properties' or 'features'). | | `responseKey` | (Non-optional when propertyBatchKey is used) The key in the response objects corresponds to `batchKey`. This should be the only field that are marked as required in your swagger endpoint response, except nestedPath. | -| `maxBatchSize` | (Optional) Limits the number of items that can be batched together in a single request. When more items are requested than this limit, multiple requests will be made. This can help prevent hitting URI length limits or timeouts for large batches. | +| `maxBatchSize` | (Optional) Limits the number of items that can be batched together in a single request. When more items are requested than this limit, multiple requests will be made. This can help prevent hitting URI length limits or timeouts for large batches. | ### `typings` diff --git a/__tests__/implementation.test.js b/__tests__/implementation.test.js index 09d93f3..fe07d33 100644 --- a/__tests__/implementation.test.js +++ b/__tests__/implementation.test.js @@ -1259,26 +1259,26 @@ test('batch endpoint with maxBatchSize', async () => { }, }, }; - + // Track each batch of IDs that the resource function receives const receivedBatches = []; - + const resources = { foo: ({ foo_ids, properties }) => { receivedBatches.push([...foo_ids]); return Promise.resolve( - foo_ids.map(id => ({ - id, - name: `name-${id}`, - rating: id + 1 - })) + foo_ids.map((id) => ({ + id, + name: `name-${id}`, + rating: id + 1, + })), ); }, }; - + await createDataLoaders(config, async (getLoaders) => { const loaders = getLoaders(resources); - + // Request 5 items at once, which should be split by maxBatchSize later in the test. const results = await Promise.all([ loaders.foo.load({ foo_id: 1, properties: ['name', 'rating'] }), @@ -1287,7 +1287,7 @@ test('batch endpoint with maxBatchSize', async () => { loaders.foo.load({ foo_id: 4, properties: ['name', 'rating'] }), loaders.foo.load({ foo_id: 5, properties: ['name', 'rating'] }), ]); - + // Verify that all results were returned correctly expect(results).toEqual([ { id: 1, name: 'name-1', rating: 2 }, @@ -1296,10 +1296,10 @@ test('batch endpoint with maxBatchSize', async () => { { id: 4, name: 'name-4', rating: 5 }, { id: 5, name: 'name-5', rating: 6 }, ]); - + // Verify that the requests were batched correctly - expect(receivedBatches.map(batch => batch.length)).toEqual([3, 2]); - + expect(receivedBatches.map((batch) => batch.length)).toEqual([3, 2]); + // Verify that all IDs were requested const allRequestedIds = receivedBatches.flat().sort(); expect(allRequestedIds).toEqual([1, 2, 3, 4, 5]); @@ -1320,26 +1320,26 @@ test('batch endpoint with propertyBatchKey and maxBatchSize', async () => { }, }, }; - + // Track each batch of IDs that the resource function receives const receivedBatches = []; - + const resources = { foo: ({ foo_ids, properties }) => { receivedBatches.push([...foo_ids]); return Promise.resolve( - foo_ids.map(id => ({ - id, - name: `name-${id}`, - rating: id + 1 - })) + foo_ids.map((id) => ({ + id, + name: `name-${id}`, + rating: id + 1, + })), ); }, }; - + await createDataLoaders(config, async (getLoaders) => { const loaders = getLoaders(resources); - + // Request 5 items at once, which should be split by maxBatchSize later in the test. const results = await Promise.all([ loaders.foo.load({ foo_id: 1, properties: ['name', 'rating'] }), @@ -1348,7 +1348,7 @@ test('batch endpoint with propertyBatchKey and maxBatchSize', async () => { loaders.foo.load({ foo_id: 4, properties: ['name', 'rating'] }), loaders.foo.load({ foo_id: 5, properties: ['name', 'rating'] }), ]); - + // Verify that all results were returned correctly expect(results).toEqual([ { id: 1, name: 'name-1', rating: 2 }, @@ -1357,10 +1357,10 @@ test('batch endpoint with propertyBatchKey and maxBatchSize', async () => { { id: 4, name: 'name-4', rating: 5 }, { id: 5, name: 'name-5', rating: 6 }, ]); - + // Verify that the requests were batched correctly - expect(receivedBatches.map(batch => batch.length)).toEqual([2, 2, 1]); - + expect(receivedBatches.map((batch) => batch.length)).toEqual([2, 2, 1]); + // Verify that all IDs were requested const allRequestedIds = receivedBatches.flat().sort(); expect(allRequestedIds).toEqual([1, 2, 3, 4, 5]);