Skip to content

Commit

Permalink
Merge pull request #134 from TriPSs/feature/relation-update-delete-op…
Browse files Browse the repository at this point in the history
…t-in

Feature/relation update delete opt in
  • Loading branch information
TriPSs committed Apr 21, 2023
2 parents 4a06092 + d049aff commit a8626b0
Show file tree
Hide file tree
Showing 101 changed files with 13,459 additions and 734 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@ name: Release

on:
workflow_dispatch:
inputs:
environment:
description: Environment
required: true
default: prod
type: choice
options:
- prod
- alpha

releaseAs:
description: Release as (Required if env = alpha)
required: false
type: choice
options:
- premajor
- preminor
- prepatch
- prerelease

env:
NX_BRANCH: ${{ github.event.number }}
Expand Down Expand Up @@ -56,8 +75,13 @@ jobs:
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: nx workspace:version
if: ${{ inputs.environment == 'prod' }}
run: yarn nx run workspace:version

- name: nx workspace:version (Alpha)
if: ${{ inputs.environment == 'alpha' }}
run: yarn nx run workspace:version --releaseAs=${{inputs.releaseAs}} --preid=alpha

- name: nx affected:build
run: node ./tools/scripts/run-many.js build origin/${{ needs.prepare-env.outputs.GITHUB_HEAD_REF }} ${{ needs.prepare-env.outputs.GITHUB_BASE_REF }}

Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ tsconfig.tsbuildinfo
# intelliJ workspace files
.idea

schema.gql

documentation/.docusaurus
/**/package-lock.json

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ $ yarn nx run-many --target=build --all
$ yarn nx run-many --target=test --all

# To run the E2E tests
$ docker-compose -f examples/docker-compose.yml up -d
$ yarn docker up -d
$ yarn nx e2e examples

# To build one package
Expand Down
4 changes: 2 additions & 2 deletions documentation/blog/2020-05-07-v0.11.0.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import { ObjectType, ID, GraphQLISODateTime } from '@nestjs/graphql';
import { TodoItemDTO } from '../todo-item/todo-item.dto.ts';

@ObjectType('SubTask')
@Relation('todoItem', () => TodoItemDTO, { disableRemove: true })
@Relation('todoItem', () => TodoItemDTO, { update: { enabled: true } })
export class SubTaskDTO {
@FilterableField(() => ID)
id!: string;
Expand Down Expand Up @@ -87,7 +87,7 @@ import { ObjectType, ID, GraphQLISODateTime } from '@nestjs/graphql';
import { SubTaskDTO } from '../sub-task/sub-task.dto'

@ObjectType('TodoItem')
@Connection('subTasks', () => SubTaskDTO, { disableRemove: true })
@Connection('subTasks', () => SubTaskDTO, { update: { enabled: true } })
export class TodoItemDTO {
@FilterableField(() => ID)
id!: string;
Expand Down
8 changes: 2 additions & 6 deletions documentation/docs/concepts/services.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,8 @@ import { SubTaskDTO } from '../../sub-task/dto/sub-task.dto';

@ObjectType('TodoItem')
@KeySet(['id'])
@FilterableConnection('subTasks', () => SubTaskDTO, { disableRemove: true })
@FilterableConnection('completedSubTasks', () => SubTaskDTO, {
// disable remove and update because it is a virtual relation
disableRemove: true,
disableUpdate: true,
})
@FilterableConnection('subTasks', () => SubTaskDTO)
@FilterableConnection('completedSubTasks', () => SubTaskDTO)
export class TodoItemDTO {
@IDField(() => ID)
id!: number;
Expand Down
12 changes: 6 additions & 6 deletions documentation/docs/graphql/authorization.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ import { UserContext } from '../../auth/auth.interfaces';

@ObjectType('TodoItem')
@Authorize({ authorize: (context: UserContext) => ({ ownerId: { eq: context.req.user.id } }) })
@FilterableRelation('owner', () => UserDTO, { disableRemove: true, disableUpdate: true })
@FilterableConnection('subTasks', () => SubTaskDTO, { disableRemove: true })
@FilterableRelation('owner', () => UserDTO)
@FilterableConnection('subTasks', () => SubTaskDTO, { update: { enabled: true } })
@FilterableConnection('tags', () => TagDTO)
export class TodoItemDTO {
@IDField(() => ID)
Expand Down Expand Up @@ -193,7 +193,7 @@ import { UserContext } from '../../auth/auth.interfaces';

@ObjectType('SubTask')
@Authorize({ authorize: (context: UserContext) => ({ ownerId: { eq: context.req.user.id } }) })
@FilterableRelation('todoItem', () => TodoItemDTO, { disableRemove: true })
@FilterableRelation('todoItem', () => TodoItemDTO, { update: { enabled: true } })
export class SubTaskDTO {
@IDField(() => ID)
id!: number;
Expand Down Expand Up @@ -237,7 +237,7 @@ For example you could define the subtasks with the `auth` option, only allowing

```ts
@FilterableConnection('subTasks', () => SubTaskDTO, {
disableRemove: true,
update: { enabled: true },
auth: {
authorize: (context: UserContext) => ({ ownerId: { eq: context.req.user.id }, completed: { is: true }}),
},
Expand Down Expand Up @@ -292,8 +292,8 @@ import { SubTaskAuthorizer } from '../sub-task.authorizer';

@ObjectType('SubTask')
@Authorize(SubTaskAuthorizer)
@FilterableRelation('owner', () => UserDTO, { disableRemove: true, disableUpdate: true })
@FilterableRelation('todoItem', () => TodoItemDTO, { disableRemove: true })
@FilterableRelation('owner', () => UserDTO)
@FilterableRelation('todoItem', () => TodoItemDTO, { update: { enabled: true } })
export class SubTaskDTO {
@IDField(() => ID)
id!: number;
Expand Down
4 changes: 2 additions & 2 deletions documentation/docs/graphql/dtos.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ import { TagDTO } from '../../tag/dto/tag.dto'
@ObjectType('TodoItem')
@KeySet(['id'])
@QueryOptions({ enableTotalCount: true })
@CursorConnection('subTasks', () => SubTaskDTO, { disableRemove: true, guards: [AuthGuard] })
@CursorConnection('tags', () => TagDTO, { guards: [AuthGuard] })
@CursorConnection('subTasks', () => SubTaskDTO, { update: { enabled: true }, guards: [AuthGuard] })
@CursorConnection('tags', () => TagDTO, { guards: [AuthGuard], update: { enabled: true }, remove: { enabled: true } })
export class TodoItemDTO {
@ObjectId()
_id: mongoose.Types.ObjectId
Expand Down
Loading

0 comments on commit a8626b0

Please sign in to comment.