Adam
10/09/2020, 1:55 PM@nexus/schema
from .15
to .16
I get an error that it can't find the `prisma.yml`file when trying to run npx prisma generate
, falling back to .15
goes back to a working statechrisdrackett
10/09/2020, 4:51 PMEric Reis
10/11/2020, 1:59 AMMikastark
10/13/2020, 4:15 PMRicardo Almeida
10/14/2020, 12:22 PMinternal/modules/cjs/loader.js:960
throw err;
^
Error: Cannot find module '@prisma/client'
Require stack:
- /app/dist/context.js
- /app/dist/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
at Function.Module._load (internal/modules/cjs/loader.js:840:27)
at Module.require (internal/modules/cjs/loader.js:1019:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (/app/dist/context.js:4:18)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Module.require (internal/modules/cjs/loader.js:1019:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/app/dist/context.js', '/app/dist/index.js' ]
}
Pieter
10/14/2020, 4:31 PMt.date
does not exist. I followed the migration guide.
import { asNexusMethod } from '@nexus/schema'
import { DateTimeResolver } from 'graphql-scalars'
const GQLDate = asNexusMethod(DateTimeResolver, 'date')
GQLDate is in my types
in makeSchema
typegenAutoConfig: {
sources: [
{
source: require.resolve('.prisma/client/index.d.ts'),
alias: 'prisma',
},
],
Pieter
10/14/2020, 5:32 PMlucas
10/14/2020, 6:00 PMSytten
10/15/2020, 1:47 PMlucas
10/15/2020, 2:28 PMexport const ChannelSubscription = subscriptionField('channel', {
type: 'Channel',
subscribe(_root, _args, ctx) {
return ctx.pubsub.asyncIterator('channel')
},
resolve(payload) {
return payload
},
})
t.field('createChannel', {
type: 'Channel',
nullable: true,
args: {
receiverId: stringArg({ nullable: false }),
},
resolve: async (_parent, { receiverId }, ctx) => {
const userId = getUserId(ctx)
const channel = await ctx.prisma.channel.create({
data: {
users: {
connect: [{ id: userId }, { id: receiverId }],
},
visibles: {
create: [{ toUserId: userId }],
},
},
})
ctx.pubsub.publish('channel', channel)
return channel
},
})
Will Fischer
10/15/2020, 2:32 PMserverInstance = await server.listen({ port });
invokes a server implementation that uses a generic PrismaClient
instance from your main app server. Obviously, that means that if you import or define your server or database differently in your project setup, you may experience different symptoms.
My solution is basically to create a server generator function that takes an optional PrismaClient
instance as an argument and use that as the database. Then in the test setup you can pass the newly created PrismaClient
to the server. Without that on the server definition, every test will attempt to refer to the client created in the first test block, even after it’s been torn down.jasonkuhrt
Jonathan
10/15/2020, 10:41 PMconnectionPlugin
? Or do you redefine the arg-types each time you want to apply the usual give me 10 of these, where the name starts with Test
kitze
10/18/2020, 1:36 PMManthan Mallikarjun
10/18/2020, 11:26 PMargs: {
categories: stringArg({ required: true, list: true }),
},
on a query field but in the resolve, category is of type: (string|null)[]
Manthan Mallikarjun
10/18/2020, 11:26 PMstring[]
?Manthan Mallikarjun
10/18/2020, 11:31 PMcategories: stringArg({ required: true, list: [true] }),
seems to work?Manthan Mallikarjun
10/19/2020, 8:25 AMPascal Sthamer
10/19/2020, 4:11 PMt.crud.updateOne*
?Pieter
10/20/2020, 9:22 PMnonNullsDefaults
=> nonNullDefaults
This typo actually breaks the migration guide and typescript is not even warning against it.Adam
10/22/2020, 2:39 PMobjectType
from @nexus/schema
there is a field for description
on both the object and for each field. As someone consuming the graphql endpoint where could I see that description
?Adam
10/22/2020, 2:40 PMPieter
10/23/2020, 5:05 PMEric Reis
10/25/2020, 11:25 PMiki
10/27/2020, 12:36 PM@nexus/schema@0.14.0
with @prisma/client@2.1.3
and have order model with related transaction field
model Order {
...
transaction Transaction
}
in Nexus API, it is exposed as
export const Order = objectType({
name: 'Order',
definition(t) {
...
t.model.transaction()
},
})
Now in one of the queries we want to change some data on the transaction for the returned order.
However, Nexus ignores the transaction field on the returned order object and always resolves it from the prisma model.
The quick workaround was to duplicate the model and change it for the query, but it's awkward, requires changing schema derived TS types on frontends and breaks fronted Apollo caching for different types.
export const CustomOrder = objectType({
name: 'CustomOrder',
definition(t) {
... // t.model('Order').xxx()
t.field('transaction', { type: 'Transaction' })
},
})
export const order = queryField('order', {
type: 'CustomOrder',
args: {
id: idArg({ required: true }),
},
resolve: async (_root, { id }, ctx) => coerceOrderTransaction(await getOrder(ctx, id)),
})
Is there any simple way to tell Nexus that we provide the resolved transaction field on given order query?Awey
10/28/2020, 3:04 AMTypeError: xs.reduce is not a function
at Object.exports.indexBy (/Users/adam/Development/epicreact/next-todo-app/node_modules/nexus-plugin-prisma/dist/utils.js:81:19)
at new DmmfDocument (/Users/adam/Development/epicreact/next-todo-app/node_modules/nexus-plugin-prisma/dist/dmmf/DmmfDocument.js:18:38)
at Object.exports.getTransformedDmmf (/Users/adam/Development/epicreact/next-todo-app/node_modules/nexus-plugin-prisma/dist/dmmf/transformer.js:16:68)
at new SchemaBuilder (/Users/adam/Development/epicreact/next-todo-app/node_modules/nexus-plugin-prisma/dist/builder.js:135:24)
at Object.build (/Users/adam/Development/epicreact/next-todo-app/node_modules/nexus-plugin-prisma/dist/builder.js:76:21)
at Object.onInstall (/Users/adam/Development/epicreact/next-todo-app/node_modules/nexus-plugin-prisma/dist/plugin.js:47:78)
at /Users/adam/Development/epicreact/next-todo-app/node_modules/@nexus/schema/dist/builder.js:299:52
at Array.forEach (<anonymous>)
at SchemaBuilder.beforeWalkTypes (/Users/adam/Development/epicreact/next-todo-app/node_modules/@nexus/schema/dist/builder.js:293:22)
at SchemaBuilder.getFinalTypeMap (/Users/adam/Development/epicreact/next-todo-app/node_modules/@nexus/schema/dist/builder.js:375:14)
I got it all working with ApolloServer/ApolloClient/@nexus/schema. When I went to add Prisma support with 'nexus-plugin-prisma' I keep getting the above error.Adam
10/28/2020, 4:36 PMinput
in my api.graphql
output that is empty, which then throwsinput manyToManyJoinTable
jasonkuhrt
Paul Hendrickson
10/29/2020, 7:42 PMmodel customer{
id Int
addressLine1 String
addressLine2 String
...
# more fields here
...
}
and I’m trying to return address as one line in my GraphQL Type. So basically trying to turn two columns in a DB to a single scalar type in GraphQL. This is what I have right now:
export const customer = objectType({
name: "customer",
definition(t) {
t.field("address", {
type: "String",
resolve: (root) => {
return root.addressLine1 + " " + root.addressLine2;
},
})
...
//more fields here
...
})
}
When I run the query I get back the response I was expecting, but typescript is telling me Property 'addressLine1' does not exist on type '{ (lists fields of other type) }'
so I thought of type typecasting the root argument in my resolve
with an interface that matched my prisma model.
interface customerSchema{
id: number
addressLine1: String
addressLine2: String
...
// more fields here
...
}
export const customer = objectType({
name: "customer",
definition(t) {
t.field("address", {
type: "String",
resolve: (root: customerSchema) => {
return root.addressLine1 + " " + root.addressLine2;
},
})
...
//more fields here
...
})
}
Which made that error go away but I’m instead getting a typescript error that says Type '(root: customerSchema => string' is not assignable to type 'FieldResolver<"Customer", "address">'.
I’m getting my expected answer when I query for address, but I’m worried I’ll run into issues in the future if I continue to use this design pattern. How should I combine two columns in a DB to output as one field in GraphQL?Ahmar Suhail
10/30/2020, 11:20 AMCORS
on my nexus server:
import { settings, use } from "nexus";
settings.change({
server: {
cors: {
origin: "*",
},
},
});
But when I try to make a request from the FE I get:
{
"event": "CORS does not work for serverless handlers. Settings will be ignored.",
"level": 4,
"path": [
"nexus",
"server"
]
}
Anyone know how I could fix this?