Akshay Kadam (A2K)
04/01/2021, 6:33 AMJSON.stringify
& JSON.parse
here? Or do I need to separate those queries into totalSum
& totalPaid
?
export const Query = queryType({
definition(t) {
t.crud.blogs()
<http://t.crud.blog|t.crud.blog>({
alias: 'blog',
})
t.nonNull.field('totalSum', {
type: 'Int', // ??
resolve: async (_root, _args, ctx: Context) => {
const totalSum = await ctx.prisma.blog.aggregate({
sum: {
price: true,
},
})
const totalPaid = await ctx.prisma.blog.aggregate({
sum: {
price: true,
},
where: {
paid: true,
},
})
return {
totalSum: totalSum.sum.price,
totalPaid: totalPaid.sum.price,
}
},
})
},
})
Michael
04/01/2021, 8:35 PMMichael
04/01/2021, 8:35 PMAlex Vilchis
04/06/2021, 6:44 PMnexus-typegen
?
import { NexusGenEnums } from 'nexus-typegen';
It seems that I always need to type the import manually 🤔Nicolas Toulemont
04/07/2021, 7:24 AMexport type CurrentUserQuery = (
{ __typename?: 'Query' }
& { currentUser?: Maybe<(
{ __typename?: 'User' }
& Pick<User, 'id'>
& { profile?: Maybe<(
{ __typename?: 'Profile' }
& Pick<Profile, 'id' | 'firstName'| 'lastName'>
)> }
) | (
{ __typename?: 'UserAuthenticationError' }
& Pick<UserAuthenticationError, 'code' | 'message'>
) | { __typename?: 'UserForbiddenError' } | { __typename?: 'InvalidArgumentsError' } | { __typename?: 'NotFoundError' } | { __typename?: 'UnableToProcessError' }> }
);
My goal is to have something like this, where both the typename and data must be generics types
if(isType('User', data.currentUser)) {
// handle user with type safety
} else {
// handle errors
}
I’ve given it a fair try but I think I’m missing something. Any ideas ?Julien Goux
04/07/2021, 4:08 PMJulien Goux
04/07/2021, 4:08 PMJulien Goux
04/07/2021, 4:08 PMJulien Goux
04/07/2021, 4:10 PMmikkelsl
04/14/2021, 11:36 AM2021-04-14T11:07:09.800837812Z $ NODE_ENV=production node build
2021-04-14T11:07:27.563867980Z /home/site/wwwroot/build/graphql/booking/area.js:47
2021-04-14T11:07:27.563898783Z t.crud.createOneArea({
2021-04-14T11:07:27.563904383Z ^
2021-04-14T11:07:27.563908584Z
2021-04-14T11:07:27.563912784Z TypeError: t.crud.createOneArea is not a function
I have used the t.crud's without any issues earlier, and it runs just fine when running the build locally. Wondering if it could be after upgrading "nexus-plugin-prisma": "^0.33.0"
. Maybe someone has experienced the same?Akshay Kadam (A2K)
04/15/2021, 1:40 PMprisma@2.19.0
& nexus@1.0.0
with nexus-plugin-prisma@0.33.0
& I'm getting the following error on `_t_.crud.acquisitions()`:
property) acquisitions: <undefined>(opts: {
type: "ERROR: No subset types are available. Please make sure that one of your GraphQL type is a subset of your t.model('<ModelName>')";
} & {
alias?: undefined;
resolve?: CustomFieldResolver<...> | undefined;
computedInputs?: LocalComputedInputs<...> | undefined;
} & NexusGenPluginFieldConfig<...> & CommonFieldConfig & {
...;
}) => NexusPrismaFields<...>
Expected 1 arguments, but got 0.ts(2554)
static.d.ts(144, 777): An argument for 'opts' was not provided.
Akshay Kadam (A2K)
04/15/2021, 1:41 PMQuery
field on `resolve`:
t.nonNull.field('getAcquisitions', {
type: 'Acquisition',
resolve: async (_root, _args, ctx: Context) => {
const acquisitions = await ctx.prisma.acquisitions.findMany()
return acquisitions
},
})
The error is:Akshay Kadam (A2K)
04/15/2021, 1:41 PMtype 'FieldResolver<"Query", "getAcquisitions">'.
Type 'Promise<acquisitions[]>' is not assignable to type '{ acquired_at?: string | null | undefined; acquired_object_id?: string | null | undefined; acquiring_object_id?: string | null | undefined; acquisition_id?: string | null | undefined; ... 6 more ...; term_code?: string | ... 1 more ... | undefined; } | PromiseLike<...> | { ...; } | PromiseLike<...>'.
Type 'Promise<acquisitions[]>' is not assignable to type 'PromiseLike<{ acquired_at?: string | null | undefined; acquired_object_id?: string | null | undefined; acquiring_object_id?: string | null | undefined; acquisition_id?: string | null | undefined; ... 6 more ...; term_code?: string | ... 1 more ... | undefined; } | { ...; }>'.
Types of property 'then' are incompatible.
Type '<TResult1 = acquisitions[], TResult2 = never>(onfulfilled?: ((value: acquisitions[]) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<...>) | ... 1 more ... | undefined) => Promise<...>' is not assignable to type '<TResult1 = { acquired_at?: string | null | undefined; acquired_object_id?: string | null | undefined; acquiring_object_id?: string | null | undefined; acquisition_id?: string | null | undefined; ... 6 more ...; term_code?: string | ... 1 more ... | undefined; } | { ...; }, TResult2 = never>(onfulfilled?: ((value: {...'.
Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible.
Types of parameters 'value' and 'value' are incompatible.
Type 'acquisitions[]' is not assignable to type '{ acquired_at?: string | null | undefined; acquired_object_id?: string | null | undefined; acquiring_object_id?: string | null | undefined; acquisition_id?: string | null | undefined; ... 6 more ...; term_code?: string | ... 1 more ... | undefined; } | { ...; }'.
Type 'acquisitions[]' has no properties in common with type '{ acquired_at?: MaybePromise<string | null | undefined>; acquired_object_id?: MaybePromise<string | null | undefined>; acquiring_object_id?: MaybePromise<string | null | undefined>; ... 7 more ...; term_code?: MaybePromise<...>; }'.ts(2322)
definitionBlocks.d.ts(160, 5): The expected type comes from property 'resolve' which is declared here on type 'NexusOutputFieldConfig<"Query", "getAcquisitions"> & { resolve: FieldResolver<"Query", "getAcquisitions">; }'
Julien Goux
04/15/2021, 9:00 PMJulien Goux
04/15/2021, 9:01 PMDregond
04/16/2021, 12:41 AMSubscription: {
onCreateUser: {
subscribe: () => pubSub.asyncIterator("SYNC"),
resolve(payload: any) {
return payload;
},
},
},
that's in resolver.ts.
I need to add the resolver types into the resolverTypes.ts, Not sure whats the correct way (below is not working)
export interface Subscription {
[key: string]: Resolver<any, any, any>;
onCreateUser?: Resolver<{}, any, Client.User>;
}
Akshay Kadam (A2K)
04/17/2021, 6:19 AMBigInt
equivalent in Nexus? Should I use _t_.float('price_amount')
?Akshay Kadam (A2K)
04/17/2021, 6:29 AMDateTime
. Had to use BigInt
the same way:
import { asNexusMethod } from 'nexus'
import { GraphQLBigInt } from 'graphql-scalars'
export const BigInt = asNexusMethod(GraphQLBigInt, 'bigint')
I do think adding it to documentation would be much betterAkshay Kadam (A2K)
04/17/2021, 6:43 AMBigInt
in an argument in minPrice
& maxPrice
:
t.nonNull.list.field('getAcquisitionsByPrice', {
type: 'Acquisition',
args: {
minPrice: nonNull(intArg()),
maxPrice: nonNull(intArg()),
undisclosed: nonNull(booleanArg()),
skip: nonNull(intArg()),
take: nonNull(intArg()),
},
It gives me an error right now: "Int cannot represent non 32-bit signed integer value: 10000000000"
Robert Witchell
04/17/2021, 12:31 PMconnectOrCreate
and computedInputs
Kevin Kelly
04/19/2021, 12:47 PMOtrebu
04/20/2021, 4:04 PM| null
while prisma client doesn't.
https://github.com/graphql-nexus/nexus/issues/819Timo
04/21/2021, 10:37 AMt.field('comments', {
type: 'Comments',
nullable: true,
args: {
first: intArg({
required: false,
}),
last: intArg({
required: false,
}),
after: stringArg({
required: false,
}),
before: stringArg({
required: false,
}),
},
resolve: async (parent, args, ctx) => {
...
},
})
fragment Post on Post {
id
author
content
comments(first: 4 <-- this should be dynamic) {
...Comment
}
}
Joseph
04/22/2021, 5:54 AMschema
is exported from nexusPiervincenzo Madeo
04/22/2021, 9:39 AMPiervincenzo Madeo
04/22/2021, 9:40 AMRobert Witchell
04/23/2021, 12:16 AMcomputedInputs
code?Philipp Humburg
04/25/2021, 8:10 AMBRob
04/28/2021, 10:17 PMBRob
04/28/2021, 10:18 PMNODE_ENV=development ts-node --transpile-only schema
on my schema but I think there must be something wrong in my types that causes it to hang