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

Add federation support #455

Merged
merged 33 commits into from
Feb 23, 2020
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c38c853
chore(federation): add deps
marcus-sa Jun 22, 2019
75df349
build: import tslib helpers
marcus-sa Jun 22, 2019
f2d5950
feat(federation): ResolveReference decorator
marcus-sa Jun 22, 2019
2c83518
feat(federation): make getTypesFromPaths method public
marcus-sa Jun 22, 2019
7e235f9
feat(federation): interfaces for gateway module options
marcus-sa Jun 22, 2019
7a0da24
refactor(federation): barrels
marcus-sa Jun 22, 2019
b090702
feat(federation): extract metadata reference resolver
marcus-sa Jun 22, 2019
ded92ce
feat(federation): graphql gateway module
marcus-sa Jun 22, 2019
d98b480
feat(federation): graphql federation factory
marcus-sa Jun 22, 2019
5948d67
feat(federation): graphql federation module
marcus-sa Jun 22, 2019
63fa587
fix(federation): filter resolvers predication
marcus-sa Jun 22, 2019
5940608
fix(federation): use resolver reference instead of resolver name
marcus-sa Jun 22, 2019
3a54832
style: formatting with prettier
rickdgeerling Oct 29, 2019
073a701
test: add integration test for federation module
rickdgeerling Oct 29, 2019
bef82ab
test: add integration test for gateway module
rickdgeerling Oct 29, 2019
ee39632
test: asynchronous federation module initialisation
rickdgeerling Oct 29, 2019
aba664f
feat: add async module support to graphql gateway
rickdgeerling Oct 29, 2019
3b9175f
test: add tests for generating interfaces for federation
rickdgeerling Oct 29, 2019
ee32547
feat: add fastify support to federation and gateway modules
rickdgeerling Oct 29, 2019
c85b139
test: add test for injecting custom buildservice into gateway
rickdgeerling Oct 30, 2019
aecc008
build: update apollo federation and gateway
rickdgeerling Oct 30, 2019
1d3ef17
fix: change GatewayModuleOptions interface
rickdgeerling Oct 30, 2019
5689b21
style: cleanup unused imports
rickdgeerling Oct 30, 2019
cf87ea7
fix: export BuildService token
rickdgeerling Oct 30, 2019
5c6e168
fix: add all options for ApolloServer to Gateway
rickdgeerling Oct 31, 2019
a5bf10b
fix: support Apollo Graph Manager
Nov 5, 2019
dfa7332
fix: scalar resolvers
Nov 6, 2019
32f395b
fix: support for external resolvers
Nov 6, 2019
77ae270
fix(federation): use type merger from 'merge-graphql-schemas'
Nov 13, 2019
bc4be48
fix(federation): allow apollo engine config in gateway
Nov 13, 2019
ef2e409
feat: add code-first support for grahql federation
rickdgeerling Nov 17, 2019
c8ba590
fix: invert logic for providing your own schema
Dec 5, 2019
48ff69c
chore(deps): remove deprecated @types/graphql dependency
Jan 20, 2020
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
Prev Previous commit
Next Next commit
test: add integration test for gateway module
  • Loading branch information
rickdgeerling authored and Rick Dutour Geerling committed Jan 20, 2020
commit bef82ab62e776bbf3b66e3072d48f570abee1b48
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
"publish:npm": "npm publish --access public",
"prepublish:next": "npm run build",
"publish:next": "npm publish --access public --tag next",
"test:integration": "jest --config ./tests/jest-e2e.json"
"test:integration": "jest --config ./tests/jest-e2e.json --runInBand"
},
"devDependencies": {
"@nestjs/common": "6.10.14",
113 changes: 113 additions & 0 deletions tests/e2e/graphql-gateway.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import { INestApplication } from '@nestjs/common';
import { Test } from '@nestjs/testing';
import * as request from 'supertest';
import { AppModule as PostsModule } from '../graphql-federation/posts-service/federation-posts.module';
import { AppModule as UsersModule } from '../graphql-federation/users-service/federation-users.module';
import { AppModule as GatewayModule } from '../graphql-federation/gateway/gateway.module';

describe('GraphQL', () => {
let postsApp: INestApplication;
let usersApp: INestApplication;
let gatewayApp: INestApplication;

beforeEach(async () => {
const usersModule = await Test.createTestingModule({
imports: [UsersModule],
}).compile();

usersApp = usersModule.createNestApplication();
await usersApp.listenAsync(3001);

const postsModule = await Test.createTestingModule({
imports: [PostsModule],
}).compile();

postsApp = postsModule.createNestApplication();
await postsApp.listenAsync(3002);

const gatewayModule = await Test.createTestingModule({
imports: [GatewayModule],
}).compile();

gatewayApp = gatewayModule.createNestApplication();
await gatewayApp.init();
});

it(`should run lookup across boundaries`, () => {
return request(gatewayApp.getHttpServer())
.post('/graphql')
.send({
operationName: null,
variables: {},
query: `
{
getPosts {
id,
title,
body,
user {
id,
name,
}
}
}`,
})
.expect(200, {
data: {
getPosts: [
{
id: '1',
title: 'Hello world',
body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
user: {
id: '5',
name: 'GraphQL',
},
},
],
},
});
});

it(`should run reverse lookup across boundaries`, () => {
return request(gatewayApp.getHttpServer())
.post('/graphql')
.send({
operationName: null,
variables: {},
query: `
{
getUser(id: "5") {
id,
name,
posts {
id,
title,
body,
}
}
}`,
})
.expect(200, {
data: {
getUser: {
id: '5',
name: 'GraphQL',
posts: [
{
id: '1',
title: 'Hello world',
body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
},
],
},
},
});
});

afterEach(async () => {
await postsApp.close();
await usersApp.close();
await gatewayApp.close();
});
});
15 changes: 15 additions & 0 deletions tests/graphql-federation/gateway/gateway.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Module } from '@nestjs/common';
import { GraphQLGatewayModule } from '../../../lib/graphql-gateway.module';
import { join } from 'path';

@Module({
imports: [
GraphQLGatewayModule.forRoot({
serviceList: [
{ name: 'users', url: 'http://localhost:3001/graphql' },
{ name: 'posts', url: 'http://localhost:3002/graphql' },
],
}),
],
})
export class AppModule {}