Skip to content

Commit

Permalink
Add default value for clientAwareness
Browse files Browse the repository at this point in the history
  • Loading branch information
danielrearden committed Jul 28, 2020
1 parent 98ffc0c commit aab6052
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Use [`revertable-globals`](https://npm.im/revertable-globals) for tests.
- Removed no longer necessary [`formdata-node`](https://npm.im/formdata-node) workarounds in tests.
- Removed `npm-debug.log` from the `.gitignore` file as npm [v4.2.0](https://github.com/npm/npm/releases/tag/v4.2.0)+ doesn’t create it in the current working directory.
- Support `clientAwareness` being undefined in Apollo Link context, via [#212](https://github.com/jaydenseric/apollo-upload-client/pull/212).

## 14.1.0

Expand Down
2 changes: 1 addition & 1 deletion src/public/createUploadLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ module.exports = function createUploadLink({
// Apollo Studio client awareness `name` and `version` can be configured
// via `ApolloClient` constructor options:
// https://apollographql.com/docs/studio/client-awareness/#using-apollo-server-and-apollo-client
clientAwareness: { name, version },
clientAwareness: { name, version } = {},
headers,
} = context;

Expand Down
18 changes: 18 additions & 0 deletions test/public/createUploadLink.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ const {
ApolloError,
ApolloLink,
concat,
execute,
gql,
InMemoryCache,
toPromise,
} = require('@apollo/client/core');
const { AbortController, AbortSignal } = require('abort-controller');
const Blob = require('fetch-blob');
Expand Down Expand Up @@ -654,6 +656,22 @@ module.exports = (tests) => {
}
);

tests.add('`createUploadLink` with `execute`.', async () => {
const link = createUploadLink({
fetch: async () =>
new Response(
JSON.stringify({ data: { a: true } }),
graphqlResponseOptionsOk
),
});
const query = '{\n a\n}\n';
const result = await toPromise(execute(link, { query: gql(query) }));

deepStrictEqual(result, {
data: { a: true },
});
});

tests.add('`createUploadLink` with errors, data.', async () => {
let fetchUri;
let fetchOptions;
Expand Down

0 comments on commit aab6052

Please sign in to comment.