Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gateway): Update managed federation to fetch "cloud config" #458

Merged
merged 39 commits into from
Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
9fdfe79
Cleanup unused import
trevor-scheer Feb 1, 2021
ff8ad3e
Initial work with marked TODOs to address
trevor-scheer Feb 1, 2021
cbe6d0e
Tests updated, TODOs still unaddressed
trevor-scheer Feb 1, 2021
afd0d79
Update tests and gateway stop() behavior
trevor-scheer Feb 3, 2021
cf491d1
Address self TODOs and cleanup
trevor-scheer Feb 4, 2021
7d11ace
Add omitted test names
trevor-scheer Feb 9, 2021
13a2287
Rework failing tests
trevor-scheer Feb 11, 2021
cdee7a3
Move try/catch down into just the dynamic branch
trevor-scheer Feb 11, 2021
6d28d75
Use relative import
trevor-scheer Feb 22, 2021
577aae8
Merge branch 'main' into trevor/fetch-csdl
trevor-scheer Mar 2, 2021
a3a6b81
Propose rename of updating functions - naming is hard
trevor-scheer Mar 2, 2021
544ddaf
Remove createSchema 'middleman' fn, can just call underlying fn appro…
trevor-scheer Mar 2, 2021
692e046
Small error improvement for health checks
trevor-scheer Mar 3, 2021
924ab56
Fix known snapshot issue
trevor-scheer Mar 4, 2021
d568bdc
Provide env variable for configuring the cloud config endpoint
trevor-scheer Mar 9, 2021
9482397
Merge branch 'main' into trevor/fetch-csdl
trevor-scheer Mar 9, 2021
ebe6be1
Replace parse fn with caching gql tag
trevor-scheer Mar 9, 2021
fb0f231
Make csdl arg non-optional
trevor-scheer Mar 9, 2021
76f7fec
Remove forgotten TODO
trevor-scheer Mar 9, 2021
9706663
Use codegen for our response types
trevor-scheer Mar 10, 2021
4c341a7
Throw when stop() is called improperly after load failure
trevor-scheer Mar 10, 2021
32c138f
Update tests to follow 4c341a7
trevor-scheer Mar 10, 2021
3aa5233
Improve fetcher config
trevor-scheer Mar 10, 2021
307ee0e
Restore former code path for managed federation
trevor-scheer Mar 11, 2021
36278d1
Naming improvements
trevor-scheer Mar 11, 2021
4214bd3
Remove comment which was previously unclear and no longer helpful
trevor-scheer Mar 11, 2021
af77271
Handle gql parse failure
trevor-scheer Mar 11, 2021
ad10a3a
Bugfix: correctly handle env override and add tests
trevor-scheer Mar 11, 2021
4cae6cb
Split manual update hook API into separate CSDL and service def updat…
trevor-scheer Mar 11, 2021
fcf5fc4
Update env vs code config behavior
trevor-scheer Mar 15, 2021
1b20599
Cleanup whitespace
trevor-scheer Mar 15, 2021
636fc1f
Don't use gql because of unbounded cache / memory leak problem
trevor-scheer Mar 15, 2021
9d4f358
Update error handling and add tests
trevor-scheer Mar 16, 2021
d67a6a6
Merge branch 'main' into trevor/fetch-csdl
trevor-scheer Mar 16, 2021
f90cdfc
Typings fix recommended by @glasser
trevor-scheer Mar 16, 2021
29d255e
Remove now incorrect comment
trevor-scheer Mar 16, 2021
b2ff29c
Small improvement to mocked-env usages
trevor-scheer Mar 16, 2021
9b2e84e
Improve error messaging
trevor-scheer Mar 16, 2021
80577a3
Add TODO issue for redundant parse calls
trevor-scheer Mar 16, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,30 @@ jobs:
steps:
- common_test_steps

GraphQL Types:
description: "Assert generated GraphQL types are up to date"
executor: { name: oss/node, tag: '14' }
steps:
- oss/install_specific_npm_version
- checkout
# Install Rust
- rust/install:
version: stable

# Setup the Cargo env in CircleCI's BASH_ENV file.
#
# It's unfortunate that the rust/install Orb doesn't do this since this
# is a CircleCI-ism. I've opened a PR in hopes of avoiding this,
# though it's possible that it's out of scope (or I'm doing smth wrong):
#
# => https://github.com/CircleCI-Public/rust-orb/pull/3
# => https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-shell-command
#
trevor-scheer marked this conversation as resolved.
Show resolved Hide resolved
- run: echo 'source $HOME/.cargo/env' >> $BASH_ENV
- oss/npm_clean_install_with_caching
- run:
command: npm run codegen:check

# XXX We used to use this filter to only run a "Docs" job on docs branches.
# Now we use it to disable all jobs. It's unclear if there's a simpler way
# to do this!
Expand Down Expand Up @@ -103,18 +127,23 @@ workflows:
- NodeJS 14:
name: "JS: Node 14"
<<: *common_non_publish_filters
- GraphQL Types:
name: "GraphQL Types (up to date)"
<<: *common_non_publish_filters
- oss/lerna_tarballs:
name: "JS: Package tarballs"
<<: *common_non_publish_filters
requires:
- "JS: Node 12"
- "JS: Node 14"
- "GraphQL Types (up to date)"
- oss/dry_run:
name: "JS: Dry-run"
<<: *common_publish_filters
requires:
- "JS: Node 12"
- "JS: Node 14"
- "GraphQL Types (up to date)"
- oss/confirmation:
name: "JS: Confirmation"
type: approval
trevor-scheer marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
9 changes: 9 additions & 0 deletions codegen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
overwrite: true
schema: "https://us-central1-mdg-services.cloudfunctions.net:443/cloudconfig-staging/"
documents:
- gateway-js/src/loadCsdlFromStorage.ts
generates:
gateway-js/src/__generated__/graphqlTypes.ts:
plugins:
- "typescript"
- "typescript-operations"
11 changes: 11 additions & 0 deletions federation-integration-testsuite-js/src/fixtures/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as documents from './documents';
import * as inventory from './inventory';
import * as product from './product';
import * as reviews from './reviews';
import * as reviewsWithUpdate from './reviewsWithUpdate'

export {
accounts,
Expand All @@ -12,6 +13,7 @@ export {
inventory,
product,
reviews,
reviewsWithUpdate
};

export const fixtures = [
Expand All @@ -23,6 +25,15 @@ export const fixtures = [
reviews,
];

export const fixturesWithUpdate = [
accounts,
books,
documents,
inventory,
product,
reviewsWithUpdate,
];

export const fixtureNames = [
accounts.name,
product.name,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import gql from 'graphql-tag';

import * as reviewsService from './reviews';

export const name = reviewsService.name;
export const url = reviewsService.url;

// For simplicity the "new" resolver just already exists - we only need to
// update the typeDefs with the newly added `review` field.
export const resolvers = reviewsService.resolvers;

// Add a new `review` field to the `Query` type
export const typeDefs = gql`
extend type Query {
review(id: ID!): Review
}
${reviewsService.typeDefs}
`;
86 changes: 86 additions & 0 deletions gateway-js/src/__generated__/graphqlTypes.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions gateway-js/src/__tests__/execution-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ export function getFederatedTestingSchema(services: ServiceDefinitionModule[] =
return { serviceMap, schema: compositionResult.schema, queryPlannerPointer };
}

export function getTestingCsdl() {
const compositionResult = composeAndValidate(fixtures);
export function getTestingCsdl(services: typeof fixtures = fixtures) {
const compositionResult = composeAndValidate(services);
if (!compositionHasErrors(compositionResult)) {
return compositionResult.composedSdl;
}
Expand Down
8 changes: 4 additions & 4 deletions gateway-js/src/__tests__/gateway/executor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ describe('ApolloGateway executor', () => {

expect(server.requestOptions.executor).toBe(gateway.executor);

expect(logger.error.mock.calls).toEqual([
["Error checking for changes to service definitions: Tried to load services from remote endpoints but none provided"],
["This data graph is missing a valid configuration. Tried to load services from remote endpoints but none provided"]
]);
expect(logger.error).toHaveBeenCalledTimes(1);
expect(logger.error).toHaveBeenCalledWith(
"This data graph is missing a valid configuration. Tried to load services from remote endpoints but none provided"
);

mockExit.mockRestore();
});
Expand Down
Loading