Adding nexus-prisma to an existing project. #169
Replies: 1 comment
-
Ok, so... A little update. I've managed to successfully add And if I try to make a nested query like so: query Course($courseId: String!) {
course(id: $courseId) {
id
name
professors {
id
name
}
}
} I get an error saying: {
"errors": [
{
"message": "Expected Iterable, but did not find one for field \"Course.professors\".",
"locations": ["..."],
"path": ["..."],
"extensions": {"..."}
}
],
"data": {
"course": {
"id": "5ed295b7-92b8-4089-af88-54ecf024b486",
"name": "Databases 1",
"professors": null
}
}
} My // Professor.ts
export const ProfessorQueries = extendType({
type: "Query",
definition(t) {
t.nonNull.list.nonNull.field("professors", {
type: "Professor",
async resolve(_, __, ctx) {
return await ctx.prisma.professor.findMany();
},
});
},
}); Now, I'm not 100% sure that i'm not doing something wrong. But after watching Jason's presentation at GraphQL Berlin Meetup #25 it looks like I'm doing the same thing as he did in that talk. I'm patiently waiting for the first fully featured version of the plugin and I have really high hopes about it. In the meantime I'll be looking for a way around the problem and maybe I'll post updates here. |
Beta Was this translation helpful? Give feedback.
-
Hi everyone!
I have a project I'm working on and I'm using Nexus intensively.
I started a while ago following along with Mahmoud and his full-stack app with Next.js, GraphQL, TypeScript & Prisma YouTube series.
Now I want to add
nexus-prisma
to the mix but I cannot find a way to do it. When using nexus-prisma something goes wrong with the schema creation and ApolloClient starts throwing reference errors about it.More specifically this shows up in the console:
error - ReferenceError: Cannot access 'schema' before initialization
. Hereschema
comes from myschema.ts
file in which I export aNexusGraphQLSchema
generated bymakeSchema
.I don't understand what's happening and since this is still in preview I couldn't find anything on how to solve the issue.
If I go back to using plain Nexus code it all works like a charm.
I was really excited about the plugin since it simplifies a LOT the code necessary to define the schema.
If you decide to help me let me know if you need some more info or anything.
Have a beautiful day!
Beta Was this translation helpful? Give feedback.
All reactions