yolen
10/22/2018, 8:02 AMconst resolvers = {
Query: {
laws(parent, args, context, info) {
return context.prisma.query.laws(
{ where: args.where, skip: args.skip, first: args.first, orderBy: args.orderBy },
info,
)
},
},
}
, but i struggle to get it working in typescript : export const Query: QueryResolvers.Type = {
...QueryResolvers.defaultResolvers,
laws: (parent, args, ctx) => ctx.db.laws({where: args.where})
}
throws the error Property 'where' does not exist on type '{}'.
I have then tried to do something like interface LawsArgs{
where?: lawsArgs.LawWhereInput;
orderBy?: lawsArgs.LawOrderByInput;
skip?: <http://lawsArgs.Int|lawsArgs.Int>;
after?: String;
before?: String;
first?: <http://lawsArgs.Int|lawsArgs.Int>;
last?: <http://lawsArgs.Int|lawsArgs.Int>;
}
export const Query: QueryResolvers.Type = {
...QueryResolvers.defaultResolvers,
laws: (parent, args:LawsArgs, ctx) => ctx.db.laws({where: args.where})
}
but still no luck.. (I am a typescript newbie :-()nilan
10/22/2018, 8:27 AMctx.db.laws(where: args.where)
yolen
10/22/2018, 8:32 AMctx.db.laws({where: args.where})
i get the error src/resolvers/Query.ts(20,57): error TS2339: Property 'where' does not exist on type '{}'.
yolen
10/22/2018, 8:33 AMnilan
10/22/2018, 8:33 AMnilan
10/22/2018, 8:34 AMnilan
10/22/2018, 8:35 AMyolen
10/22/2018, 8:39 AMwhere
but I struggle to use the args. I have searched all the typescript examples in https://github.com/prisma/prisma-examples but there are not examples passing arguments e.g. as in javascript (works perfectly) return context.prisma.query.laws(
{ where: args.where, skip: args.skip, first: args.first, orderBy: args.orderBy },
yolen
10/22/2018, 8:40 AMnilan
10/22/2018, 8:41 AMa
, b
, c
, so you can at least do this:
const {a, b, c} = ...args.where
ctx.db.laws({where: {a, b, c}})
yolen
10/22/2018, 8:44 AMnilan
10/22/2018, 8:44 AMctx.db.laws({where: ...args.where})
?nilan
10/22/2018, 8:45 AMyolen
10/22/2018, 8:47 AMsrc/resolvers/Query.ts(21,52): error TS1109: Expression expected.
src/resolvers/Query.ts(21,60): error TS2339: Property 'where' does not exist on type '{}'.
nilan
10/22/2018, 8:47 AMyolen
10/22/2018, 8:49 AMnilan
10/22/2018, 8:50 AMyolen
10/22/2018, 10:14 AMlaws: [Law!]!
with laws(where: LawWhereInput, skip: Int, first: Int, orderBy: LawOrderByInput): [Law!]!
but this lead to the error: src/resolvers/Query.ts(9,45): error TS2322: Type 'import("/home/jens/Desktop/onlaw.dk/packages/graphql/src/generated/graphqlgen").QueryResolvers.LawWhereInput' is not assignable to type 'import("/home/jens/Desktop/onlaw.dk/packages/graphql/src/generated/prisma-client/index").LawWhereInput'.
Types of property 'justiceSystem' are incompatible.
Type 'string' is not assignable to type 'JusticeSystemEnum'.
yolen
10/22/2018, 10:18 AMjusticeSystem: string
nilan
10/23/2018, 8:45 AMyolen
10/23/2018, 9:37 AM