-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
65 changed files
with
7,287 additions
and
868 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { IntrospectAndCompose } from '@apollo/gateway' | ||
import { ApolloGatewayDriver, ApolloGatewayDriverConfig } from '@nestjs/apollo' | ||
import { Module } from '@nestjs/common' | ||
import { GraphQLModule } from '@nestjs/graphql' | ||
|
||
@Module({ | ||
imports: [ | ||
GraphQLModule.forRoot<ApolloGatewayDriverConfig>({ | ||
driver: ApolloGatewayDriver, | ||
gateway: { | ||
supergraphSdl: new IntrospectAndCompose({ | ||
subgraphs: [ | ||
{ name: 'todo-items', url: 'http://localhost:3001/graphql' }, | ||
{ name: 'sub-tasks', url: 'http://localhost:3002/graphql' }, | ||
{ name: 'tags', url: 'http://localhost:3003/graphql' }, | ||
{ name: 'user', url: 'http://localhost:3004/graphql' } | ||
] | ||
}) | ||
} | ||
}) | ||
] | ||
}) | ||
export class AppModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ValidationPipe } from '@nestjs/common' | ||
import { NestFactory } from '@nestjs/core' | ||
|
||
import { AppModule } from './app.module' | ||
|
||
async function bootstrap(): Promise<void> { | ||
const app = await NestFactory.create(AppModule) | ||
|
||
app.useGlobalPipes( | ||
new ValidationPipe({ | ||
transform: true, | ||
whitelist: true, | ||
forbidNonWhitelisted: true, | ||
skipMissingProperties: false, | ||
forbidUnknownValues: true | ||
}) | ||
) | ||
|
||
await app.listen(3000) | ||
} | ||
|
||
// eslint-disable-next-line no-void | ||
void bootstrap() |
29 changes: 29 additions & 0 deletions
29
examples/federation-v2/sub-task-graphql/e2e/__fixtures__/graphql-fragments.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
export const todoItemFields = ` | ||
id | ||
` | ||
|
||
export const subTaskFields = ` | ||
id | ||
title | ||
description | ||
completed | ||
todoItemId | ||
` | ||
|
||
export const pageInfoField = ` | ||
pageInfo{ | ||
hasNextPage | ||
hasPreviousPage | ||
startCursor | ||
endCursor | ||
} | ||
` | ||
|
||
export const edgeNodes = (fields: string): string => ` | ||
edges { | ||
node{ | ||
${fields} | ||
} | ||
cursor | ||
} | ||
` |
34 changes: 34 additions & 0 deletions
34
examples/federation-v2/sub-task-graphql/e2e/__fixtures__/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Connection } from 'typeorm' | ||
|
||
import { executeTruncate } from '../../../../helpers' | ||
import { SubTaskEntity } from '../../src/sub-task/sub-task.entity' | ||
|
||
const tables = ['sub_task'] | ||
export const truncate = async (connection: Connection): Promise<void> => executeTruncate(connection, tables) | ||
|
||
export const refresh = async (connection: Connection): Promise<void> => { | ||
await truncate(connection) | ||
|
||
const todoItems = [ | ||
{ id: 1, title: 'Create Nest App' }, | ||
{ id: 2, title: 'Create Entity' }, | ||
{ id: 3, title: 'Create Entity Service' }, | ||
{ id: 4, title: 'Add Todo Item Resolver' }, | ||
{ id: 5, title: 'How to create item With Sub Tasks' } | ||
] | ||
const subTaskRepo = connection.getRepository(SubTaskEntity) | ||
|
||
await subTaskRepo.save( | ||
todoItems.reduce( | ||
(subTasks, todo) => [ | ||
...subTasks, | ||
{ completed: true, title: `${todo.title} - Sub Task 1`, todoItemId: todo.id }, | ||
{ completed: false, title: `${todo.title} - Sub Task 2`, todoItemId: todo.id }, | ||
{ completed: false, title: `${todo.title} - Sub Task 3`, todoItemId: todo.id } | ||
], | ||
[] as Partial<SubTaskEntity>[] | ||
) | ||
) | ||
} | ||
|
||
export * from './graphql-fragments' |
Oops, something went wrong.