Skip to content

Commit

Permalink
feat(backend): expose folder statuses (#80)
Browse files Browse the repository at this point in the history
* feat(backend): expose folder statuses

fix: files changed

fix: files changed

fix: files changed

fix: files changed

* chore: exclude release versions

* chore: add changeset

* test: update integration tests for creating a folder
  • Loading branch information
tericcabrel committed Jun 23, 2024
1 parent 2244243 commit 424abe8
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 25 deletions.
6 changes: 6 additions & 0 deletions .changeset/breezy-guests-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@snipcode/domain': patch
'@snipcode/backend': patch
---

Change folder status in the database end exposes them in the through the api
4 changes: 2 additions & 2 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ jobs:
id: changesets
uses: changesets/action@v1
with:
commit: 'chore: update versions'
title: 'chore: update versions'
commit: 'chore: update release versions'
title: 'update release versions'
createGithubReleases: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
28 changes: 7 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ concurrency:
jobs:
build:
runs-on: ubuntu-latest
# Defined in .github/workflows/build-release.yml at the "Create Release Pull Request" step
if: ${{ github.event.pull_request.title != 'update release versions' }}
env:
NODE_ENV: test
MYSQL_ROOT_PASSWORD: root
Expand Down Expand Up @@ -44,10 +46,8 @@ jobs:
yarn prisma migrate dev --schema=packages/domain/prisma/schema.prisma
yarn test -- --runInBand --coverage
should-preview-frontend:
runs-on: ubuntu-latest
environment: 'Preview'
needs:
- build
outputs:
Expand All @@ -59,26 +59,16 @@ jobs:
id: frontend-changed
uses: tj-actions/changed-files@v44
with:
files_yaml: |
apps:
- apps/web/**
packages:
- packages/front/**
- name: Run step if test file(s) change
env:
ALL_CHANGED_FILES: ${{ steps.frontend-changed.outputs.all_changed_files }}
run: |
echo "Change state: ${{ steps.frontend-changed.outputs.any_changed }}"
echo "One or more test file(s) has changed."
echo "List all the files that have changed: $ALL_CHANGED_FILES"
files: |
apps/web/**
packages/front/**
preview-frontend:
runs-on: ubuntu-latest
environment: 'Preview'
needs:
- should-preview-frontend
if: ${{ needs.should-preview-frontend.frontendChanged == 'true' }}
if: ${{ needs.should-preview-frontend.outputs.frontendChanged == 'true' }}
steps:
- uses: actions/checkout@v4

Expand All @@ -88,19 +78,15 @@ jobs:
yarn set version 4.2.2
- name: Install Vercel CLI
if: ${{ success() }}
run: npm install --global vercel@latest

- name: Pull Vercel Environment Information
if: ${{ success() }}
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}

- name: Build Project Artifacts
if: ${{ success() }}
env:
APP_VERSION:
APP_VERSION: ${{ github.sha }}
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}

- name: Deploy Project Artifacts to Vercel
if: ${{ success() }}
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ describe('Test Folder Feature', () => {
id
name
isFavorite
isArchived
isHidden
subFolders {
id
}
Expand Down Expand Up @@ -163,7 +165,9 @@ describe('Test Folder Feature', () => {
expect(createFolder).toMatchObject({
__typename: 'Folder',
id: expect.any(String),
isArchived: false,
isFavorite: false,
isHidden: false,
name: 'My First Folder',
parent: { id: user.rootFolderId },
subFolders: [],
Expand Down
14 changes: 12 additions & 2 deletions apps/backend/src/features/folders/graphql/folder.resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,17 @@ export class FolderResolvers {
}

@ResolveField()
async isFavorite(@Parent() _folder: Folder): Promise<boolean> {
return false;
async isFavorite(@Parent() folder: Folder): Promise<boolean> {
return folder.category === 'favorite';
}

@ResolveField()
async isArchived(@Parent() folder: Folder): Promise<boolean> {
return folder.category === 'archived';
}

@ResolveField()
async isHidden(@Parent() folder: Folder): Promise<boolean> {
return folder.category === 'hidden';
}
}
2 changes: 2 additions & 0 deletions apps/backend/src/features/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ type Folder {
id: ID!
name: String!
isFavorite: Boolean!
isArchived: Boolean!
isHidden: Boolean!
createdAt: Date!
updatedAt: Date!
user: User!
Expand Down
2 changes: 2 additions & 0 deletions apps/backend/src/types/graphql.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ export interface Folder {
id: string;
name: string;
isFavorite: boolean;
isArchived: boolean;
isHidden: boolean;
createdAt: Date;
updatedAt: Date;
user: User;
Expand Down

0 comments on commit 424abe8

Please sign in to comment.