Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

effect dependency update #28

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
**/node_modules
**/dist
dev.db
src/tests/fixtures/prisma-client
src/tests/fixtures/prisma-client

.idea/
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@
}
},
"scripts": {
"seed": "rm ./prisma/dev.db && prisma db push && tsx prisma/seed.ts",
"test": "pnpm seed && NODE_OPTIONS=--experimental-vm-modules jest --watch",
"prisma:generate": "mkdir -p src/tests/fixtures/prisma-client && prisma generate",
"seed": "rm -f ./prisma/dev.db && prisma db push && tsx prisma/seed.ts",
"test": "pnpm prisma:generate && pnpm seed && NODE_OPTIONS=--experimental-vm-modules jest --watch",
"build": "nanobundle build --external '@prisma/generator-helper' --external 'ts-morph'",
"prepack": "pnpm build",
"release": "release-it"
Expand Down Expand Up @@ -65,7 +66,7 @@
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"camelcase": "^8.0.0",
"effect": "2.0.0-next.32",
"effect": "2.2.2",
"eslint": "^8.49.0",
"eslint-plugin-dprint-integration": "^0.3.0",
"graphql": "^16.8.0",
Expand Down
60 changes: 4 additions & 56 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions src/field-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ function checkAndThrowResultIfFailure<E, A>(
result: Exit.Exit<E, A>,
FailErrorConstructor: { new(message: string): unknown } = Error,
): asserts result is Exit.Success<E, A> {
// Check if result is a failure
if (Exit.isFailure(result)) {
const cause = Cause.unannotate(result.cause);
const cause = result.cause;

// TODO: shoud it handle empty/die/interrupt/etc cases?
if (Cause.isFailType(cause) && (cause.error as unknown) instanceof Error) {
Expand Down Expand Up @@ -149,8 +148,8 @@ async function resolveEffectField(
// Provide layer and context to resolve field effect
const program = pipe(
fieldResult as Effect.Effect<never, never, any>,
Effect.provideSomeLayer(layer),
Effect.provideSomeContext(context),
Effect.provide(layer),
Effect.provide(context),
);

// Run effect via runPromiseExit to handle error or success value
Expand Down
2 changes: 1 addition & 1 deletion src/tests/integrate-errors.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import SchemaBuilder from '@pothos/core';
import ErrorsPlugin from '@pothos/plugin-errors';
import EffectPlugin from '../index';
import { Cause, Effect } from 'effect/index';
import { Cause, Effect } from 'effect';
import { execute, parse } from 'graphql';

class ForbiddenError extends Error {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"resolveJsonModule": true,
"outDir": "./dist"
},
"include": ["src", "src/tests"]
"include": ["src", "src/tests", "node_modules/@pothos/plugin-prisma"]
}