@apollo/gateway 0.42.2 → 0.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,8 +5,8 @@ import { SupergraphSdlQuery } from './__generated__/graphqlTypes';
5
5
 
6
6
  // Magic /* GraphQL */ comment below is for codegen, do not remove
7
7
  export const SUPERGRAPH_SDL_QUERY = /* GraphQL */`#graphql
8
- query SupergraphSdl($apiKey: String!, $ref: String!) {
9
- routerConfig(ref: $ref, apiKey: $apiKey) {
8
+ query SupergraphSdl($apiKey: String!, $ref: String!, $ifAfterId: ID) {
9
+ routerConfig(ref: $ref, apiKey: $apiKey, ifAfterId: $ifAfterId) {
10
10
  __typename
11
11
  ... on RouterConfigResult {
12
12
  id
@@ -43,11 +43,13 @@ export async function loadSupergraphSdlFromStorage({
43
43
  apiKey,
44
44
  endpoint,
45
45
  fetcher,
46
+ compositionId,
46
47
  }: {
47
48
  graphRef: string;
48
49
  apiKey: string;
49
50
  endpoint: string;
50
51
  fetcher: typeof fetch;
52
+ compositionId: string | null;
51
53
  }) {
52
54
  let result: Response;
53
55
  const requestDetails = {
@@ -57,6 +59,7 @@ export async function loadSupergraphSdlFromStorage({
57
59
  variables: {
58
60
  ref: graphRef,
59
61
  apiKey,
62
+ ifAfterId: compositionId,
60
63
  },
61
64
  }),
62
65
  headers: {
@@ -124,13 +127,13 @@ export async function loadSupergraphSdlFromStorage({
124
127
  supergraphSdl,
125
128
  // messages,
126
129
  } = routerConfig;
127
-
128
- // `supergraphSdl` should not be nullable in the schema, but it currently is
129
130
  return { id, supergraphSdl: supergraphSdl! };
130
131
  } else if (routerConfig.__typename === 'FetchError') {
131
132
  // FetchError case
132
133
  const { code, message } = routerConfig;
133
134
  throw new Error(`${code}: ${message}`);
135
+ } else if (routerConfig.__typename === 'Unchanged') {
136
+ return null;
134
137
  } else {
135
138
  throw new Error('Programming error: unhandled response failure');
136
139
  }