Skip to content

Commit

Permalink
Fix createServicesFetcher handle null service url (#563)
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloSzx authored Oct 31, 2022
1 parent c47df83 commit d58a470
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/famous-readers-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-hive/client': minor
---

Fix createServicesFetcher handling null service url
14 changes: 11 additions & 3 deletions packages/libraries/client/src/gateways.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { SchemaFetcherOptions, ServicesFetcherOptions } from './internal/ty

interface Schema {
sdl: string;
url: string;
url: string | null;
name: string;
}

Expand Down Expand Up @@ -62,7 +62,11 @@ export function createSchemaFetcher({ endpoint, key }: SchemaFetcherOptions) {

return function schemaFetcher() {
return fetcher().then(schema => ({
id: createHash('sha256').update(schema.sdl).update(schema.url).update(schema.name).digest('base64'),
id: createHash('sha256')
.update(schema.sdl)
.update(schema.url || '')
.update(schema.name)
.digest('base64'),
...schema,
}));
};
Expand All @@ -74,7 +78,11 @@ export function createServicesFetcher({ endpoint, key }: ServicesFetcherOptions)
return function schemaFetcher() {
return fetcher().then(services =>
services.map(service => ({
id: createHash('sha256').update(service.sdl).update(service.url).update(service.name).digest('base64'),
id: createHash('sha256')
.update(service.sdl)
.update(service.url || '')
.update(service.name)
.digest('base64'),
...service,
}))
);
Expand Down

0 comments on commit d58a470

Please sign in to comment.