Skip to content

Commit

Permalink
fix(graphql): Use the provided connection name (#204)
Browse files Browse the repository at this point in the history
Fixes #201
  • Loading branch information
TriPSs committed Dec 1, 2023
2 parents 491d589 + 1fb51db commit b103072
Show file tree
Hide file tree
Showing 26 changed files with 4,146 additions and 1 deletion.
47 changes: 47 additions & 0 deletions examples/all-paging/e2e/fixtures.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Connection } from 'typeorm'

import { executeTruncate } from '../../helpers'
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'

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

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

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

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 = await todoRepo.save([
{ title: 'Create Nest App', completed: true, tags: [urgentTag, homeTag] },
{ title: 'Create Entity', completed: false, tags: [urgentTag, workTag] },
{ title: 'Create Entity Service', completed: false, tags: [blockedTag, workTag] },
{ title: 'Add Todo Item Resolver', completed: false, tags: [blockedTag, homeTag] },
{
title: 'How to create item With Sub Tasks',
completed: false,
tags: [questionTag, blockedTag]
}
])

await subTaskRepo.save(
todoItems.reduce(
(subTasks, todo) => [
...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>[]
)
)
}
55 changes: 55 additions & 0 deletions examples/all-paging/e2e/graphql-fragments.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
export const todoItemFields = `
id
title
completed
description
`

export const subTaskFields = `
id
title
description
completed
todoItemId
`

export const tagFields = `
id
name
`

export const offsetPageInfoField = `
pageInfo{
hasNextPage
hasPreviousPage
}
`

export const cursorPageInfoField = `
pageInfo{
hasNextPage
hasPreviousPage
startCursor
endCursor
}
`

export const nodes = (fields: string): string => `
nodes {
${fields}
}
`

export const offsetConnection = (fields: string): string => `
${nodes(fields)}
${offsetPageInfoField}
`

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

0 comments on commit b103072

Please sign in to comment.