Skip to content

Commit

Permalink
feat(auth): Initial Investigation
Browse files Browse the repository at this point in the history
  • Loading branch information
doug-martin committed Aug 31, 2020
1 parent c77d778 commit 8d40636
Show file tree
Hide file tree
Showing 46 changed files with 4,343 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .run/start - auth.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="start - auth" type="js.build_tools.npm">
<package-json value="$PROJECT_DIR$/examples/package.json" />
<command value="run" />
<scripts>
<script value="start" />
</scripts>
<arguments value="-- auth" />
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
</component>
59 changes: 59 additions & 0 deletions examples/auth/e2e/fixtures.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { Connection } from 'typeorm';
import { SubTaskEntity } from '../src/sub-task/sub-task.entity';
import { TagEntity } from '../src/tag/tag.entity';
import { TodoItemEntity } from '../src/todo-item/todo-item.entity';
import { executeTruncate } from '../../helpers';
import { UserEntity } from '../src/user/user.entity';

const tables = ['todo_item', 'sub_task', 'tag', 'user'];
export const truncate = async (connection: Connection): Promise<void> => executeTruncate(connection, tables);

export const refresh = async (connection: Connection): Promise<void> => {
await truncate(connection);

const userRepo = connection.getRepository(UserEntity);
const todoRepo = connection.getRepository(TodoItemEntity);
const subTaskRepo = connection.getRepository(SubTaskEntity);
const tagsRepo = connection.getRepository(TagEntity);

const users = await userRepo.save([
{ username: 'nestjs-query', password: '123' },
{ username: 'nestjs-query-2', password: '123' },
{ username: 'nestjs-query-3', password: '123' },
]);

const urgentTag = await tagsRepo.save({ name: 'Urgent' });
const homeTag = await tagsRepo.save({ name: 'Home' });
const workTag = await tagsRepo.save({ name: 'Work' });
const questionTag = await tagsRepo.save({ name: 'Question' });
const blockedTag = await tagsRepo.save({ name: 'Blocked' });

const todoItems: TodoItemEntity[] = await users.reduce(async (prev, user) => {
const allTodos = await prev;
const userTodos = await todoRepo.save([
{ title: 'Create Nest App', completed: true, priority: 0, tags: [urgentTag, homeTag], owner: user },
{ title: 'Create Entity', completed: false, priority: 1, tags: [urgentTag, workTag], owner: user },
{ title: 'Create Entity Service', completed: false, priority: 2, tags: [blockedTag, workTag], owner: user },
{ title: 'Add Todo Item Resolver', completed: false, priority: 3, tags: [blockedTag, homeTag], owner: user },
{
title: 'How to create item With Sub Tasks',
completed: false,
priority: 4,
tags: [questionTag, blockedTag],
owner: user,
},
]);
return [...allTodos, ...userTodos];
}, Promise.resolve([] as TodoItemEntity[]));

await subTaskRepo.save(
todoItems.reduce((subTasks, todo) => {
return [
...subTasks,
{ completed: true, title: `${todo.title} - Sub Task 1`, todoItem: todo },
{ completed: false, title: `${todo.title} - Sub Task 2`, todoItem: todo },
{ completed: false, title: `${todo.title} - Sub Task 3`, todoItem: todo },
];
}, [] as Partial<SubTaskEntity>[]),
);
};
118 changes: 118 additions & 0 deletions examples/auth/e2e/graphql-fragments.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
export const todoItemFields = `
id
title
completed
description
age
`;

export const subTaskFields = `
id
title
description
completed
todoItemId
`;

export const tagFields = `
id
name
`;

export const pageInfoField = `
pageInfo{
hasNextPage
hasPreviousPage
startCursor
endCursor
}
`;

export const edgeNodes = (fields: string): string => {
return `
edges {
node{
${fields}
}
cursor
}
`;
};

export const todoItemAggregateFields = `
count {
id
title
description
completed
created
updated
}
sum {
id
}
avg {
id
}
min {
id
title
description
}
max {
id
title
description
}
`;

export const tagAggregateFields = `
count {
id
name
created
updated
}
sum {
id
}
avg {
id
}
min {
id
name
}
max {
id
name
}
`;

export const subTaskAggregateFields = `
count {
id
title
description
completed
todoItemId
}
sum {
id
}
avg {
id
}
min {
id
title
description
todoItemId
}
max {
id
title
description
todoItemId
}
`;
Loading

0 comments on commit 8d40636

Please sign in to comment.