Skip to content

Commit

Permalink
Add Args types for rules (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
utkarsh867 authored Jan 17, 2023
1 parent b698be3 commit 452183d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
14 changes: 11 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import "reflect-metadata";
import { ResolverData } from "type-graphql";
import { ArgsDictionary, ResolverData } from "type-graphql";

export type Rule<TContextType = {}> = (
D: ResolverData<TContextType>
export interface ResolverDataWithArgs<
TArgsType extends ArgsDictionary,
TContextType = {}
> extends ResolverData<TContextType> {
args: TArgsType;
context: TContextType;
}

export type Rule<TContextType = {}, TArgsType extends ArgsDictionary = {}> = (
D: ResolverDataWithArgs<TArgsType, TContextType>
) => boolean | Promise<boolean>;

export type Rules<TContextType = {}> =
Expand Down
2 changes: 1 addition & 1 deletion tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "reflect-metadata";

import { authResolver, Rules } from "../src";
import { authResolver } from "../src";

const ruleIsTrue = (): boolean => {
console.log("sync ruleIsTrue");
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2976,11 +2976,6 @@ readdirp@~3.6.0:
dependencies:
picomatch "^2.2.1"

reflect-metadata@^0.1.13:
version "0.1.13"
resolved "https://registry.yarnpkg.com/reflect-metadata/-/reflect-metadata-0.1.13.tgz#67ae3ca57c972a2aa1642b10fe363fe32d49dc08"
integrity sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==

regenerate-unicode-properties@^9.0.0:
version "9.0.0"
resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-9.0.0.tgz#54d09c7115e1f53dc2314a974b32c1c344efe326"
Expand Down

0 comments on commit 452183d

Please sign in to comment.