Skip to content
This repository has been archived by the owner on Jan 6, 2025. It is now read-only.

Commit

Permalink
1.0 (#29)
Browse files Browse the repository at this point in the history
* Update workspace, refactor codes and ready for start development again

* Rewrite core logic

* Fix type inferrence with nullable

* Resolve promise value

* Rewrite integration with errors plugin

* Split relay integration

* Improve types for t.effectConnection

* Add prisma integration

* Change api. only keep t.effect

* Add one case which using Drizzle ORM

* Symlink README.md

* Update README.md

* Update test case

* Write contributing, migration docs

* Setup changesets

* setup codecov

* Enable corepack

* Add cache input

* Fix ci

* Add codecov badge
  • Loading branch information
iamchanii authored Feb 7, 2024
1 parent dfa509a commit cd8cb50
Show file tree
Hide file tree
Showing 87 changed files with 7,614 additions and 9,888 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
10 changes: 10 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"mode": "pre",
"tag": "next",
"initialVersions": {
"pothos-plugin-effect": "0.8.0"
},
"changesets": [
"tricky-months-protect"
]
}
5 changes: 5 additions & 0 deletions .changeset/tricky-months-protect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"pothos-plugin-effect": major
---

1.0
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[*.ts]
indent_style = space
indent_size = 2
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

22 changes: 0 additions & 22 deletions .eslintrc.cjs

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI

on:
pull_request_target:
types: [assigned, opened, synchronize, reopened]
push:
branches:
- main
- next

jobs:
test:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- run: corepack enable

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.tool-versions'
cache: 'yarn'

- name: Install Dependencies
run: yarn

- name: Run Test
run: yarn test --coverage

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Release

on:
push:
branches:
- main
- next

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- run: corepack enable

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.tool-versions'
cache: 'yarn'

- name: Install Dependencies
run: yarn

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
version: yarn changeset version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
13 changes: 9 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
**/node_modules
**/dist
dev.db
src/tests/fixtures/prisma-client

.idea/
.idea/
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
**/coverage
10 changes: 0 additions & 10 deletions .release-it.json

This file was deleted.

1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 20.11.0
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["editorconfig.editorconfig", "biomejs.biome"]
}
11 changes: 5 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"prettier.enable": false,
"editor.formatOnSave": true,
"eslint.format.enable": true,
"[typescript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"typescript.tsdk": "node_modules/typescript/lib"
"editor.defaultFormatter": "biomejs.biome",
"typescript.tsdk": "node_modules/typescript/lib",
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nmMode: hardlinks-global
nodeLinker: node-modules
14 changes: 5 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
## Install
# Contributing Guide

```sh
pnpm install
```
## Install Node.js

## Run tests
Install the version of Node.js specified in `.tool-versions`. It doesn't matter how, I personally recommend to use asdf-vm for manage Node.js version.

```sh
pnpm test
```
## Run Test

This command will be remove `./prisma/dev.db` (if exists), run `prisma db push` to create new `dev.db` and setup database data to running test cases about Prisma plugin integration.
You can run `vitest` using `yarn test` in project root. Write test cases for major changes.
54 changes: 54 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Migration from v0.x

The 1.0 release contains a large number of breaking changes. If you're using [email protected] (thanksfully), follow the instructions below.

## `t.effect` is not field builder.

`t.effect` is provided as a utility function rather than in the field builder. Use `t.effect` inside any kind of Pothos field resolver function to resolve the Effect.

```ts
t.int({
resolve: () => t.effect(Effect.succeed(1)),
});
```

## Removed service/context/layer configuration options at field level.

Instead, you can [configure a custom effect runtime](/README.md#configure-custom-runtime).

## Removed `t.effectConnection`

Instead, you can directly use the `resolveArrayConnection`/`resolveCursorConnection`/`resolveOffsetConnection` which imported from [`@pothos/plugin-relay`](https://pothos-graphql.dev/docs/plugins/relay), with `t.effect`. Below is an example code for using `resolveArrayConnection`:

```ts
t.connection({
type: "String",
resolve: async (_root, args) => {
return resolveArrayConnection(
{ args },
await t.effect(Effect.succeed(["1", "2", "3", "4"]))
);
},
});
```

## Removed `t.prismaEffect` (aka Prisma Integration)

`t.effect` works even if the end result of the Effect is a Promise.

```ts
t.prismaField({
type: "User",
resolve: (query) =>
t.effect(
pipe(
PrismaClient,
Effect.map((prisma) => prisma.user.findFirstOrThrow({ ...query }))
)
),
});
```

## Removed error type inferring

Removed `errors.types` inference functionality provided by integration with the errors plugin.
50 changes: 0 additions & 50 deletions README.md

This file was deleted.

1 change: 1 addition & 0 deletions README.md
2 changes: 0 additions & 2 deletions bin/generator.mjs

This file was deleted.

35 changes: 35 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
"organizeImports": {
"enabled": true
},
"formatter": {
"indentWidth": 2,
"indentStyle": "space"
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"style": {
"noUnusedTemplateLiteral": "off"
},
"suspicious": {
"noExplicitAny": "off",
"noShadowRestrictedNames": "off",
"noEmptyInterface": "off",
"noRedeclare": "off"
},
"complexity": {
"noBannedTypes": "off"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"jsxQuoteStyle": "double",
"semicolons": "always"
}
}
}
Empty file removed docs/.keep
Empty file.
Loading

0 comments on commit cd8cb50

Please sign in to comment.