Questions tagged [nexus-js]

16 questions
15
votes
1 answer

Nexus Prisma - How to handle createdAt and updatedAt with crud globally?

First thing I came up with, is by calling computedInputs in the nexusPrisma option. But it won't work since they need to be handled differently depending on the situation, but globally: 1. create -> createdAt = now, updatedAt = null 2. update ->…
Eliya Cohen
  • 10,716
  • 13
  • 59
  • 116
3
votes
0 answers

Type Error for When Creating Many-to-one Relation Field on GraphQL Nexus

I am using Next.js and its api routes, Graphql, Nexus, Prisma for my web app. I got type error when I am creating a many-to-one relation field for the schema with Nexus. Seems that the return type from resolver does not match what it want. export…
Andrew Li
  • 117
  • 1
  • 8
3
votes
3 answers

How to pass an array as args to Nexus? How to create multiple objects from this array using Prisma?

I'm trying to learn to use Prisma and Nexus together. I'm hoping that someone more experienced can help me out. I want to create a post with several images attached to it. My Prisma models look like this: model Post { id String @id…
lumenwrites
  • 1,287
  • 4
  • 18
  • 35
2
votes
0 answers

Pass next-auth session to prisma via nexus

I'm wondering on how to pass the next-auth session as context to my nexus queries. The reson behind is that I want the sessions email to retrieve data from my database with nexus. I'm also using Apollo Server and next-connect here. Here's what I…
Felix Haeberle
  • 1,530
  • 12
  • 19
2
votes
0 answers

Error: Expected [object Object] to be a possible input type, saw GraphQLObjectType(Category)

I am trying to get trying to create a Product with the following fields, however whenever I try to have my categories object within my Product Object equal an actual Category Object that is already made I get the error above. I want to have an…
Esore
  • 243
  • 2
  • 9
1
vote
1 answer

Prisma 4 and prisma.$subscribe

in Prisma 1 was really nice use of subscrition with prisma.$subscribe - documentation. I look for same doc for Prisma@4.6 but in documentation is nothing about it and I found only notice that in Prisma@2 is still not implemented and maybe it will be…
Petr Mašát
  • 525
  • 1
  • 5
  • 6
1
vote
0 answers

Why is my context not typed on my Nexus, Prisma, TS project?

I'm practicing setting up a Nexus, Prisma, TS API and am having issues getting my context typed on the resolvers. src/context.ts: import { PrismaClient } from "@prisma/client" import { prisma } from "./db" export interface Context { prisma:…
Tiago Brandão
  • 207
  • 3
  • 12
1
vote
1 answer

Query an interface that implements another interface in GraphQL

I'm currently working on an Activity Feed built using GraphQL Nexus and Apollo Server (3.9.0). It will receive a flurry of information that will have shared fields that are handled by a shared IActivity interface. In addition, there will be types…
Jose A
  • 10,053
  • 11
  • 75
  • 108
1
vote
1 answer

Nexus resolve() returns PrismaPromise but gives error

I am trying to build an apollo server with Nexus.js, Prisma and Typescript for a to-do app. I created the Todo nexus type, and I wanted to create the query, but I'm having an error. The definition: import { extendType, objectType } from…
Essay97
  • 648
  • 1
  • 9
  • 24
1
vote
3 answers

NexusJS Error: TypeError: Class constructor GraphQLNonNull cannot be invoked without 'new'

I was trying to learn nexus, but got a problems. I created index.ts file with this code: const User = objectType({ name: 'User', definition(t) { t.id('id') t.string('name') } }) export const schema = makeSchema({ types: [User], …
Zelleaz
  • 31
  • 1
  • 3
1
vote
0 answers

How to augment the ObjectDefinitionBlock when definiting a type in GraphQL Nexus.js?

I am using nexus.js to build GraphQL schema. To define a type, we use ObjectDefinitionBlock. I define the object type as following: export const Choice = objectType({ name: 'Choice', definition(t) { t.id('id', { resolve: (x) =>…
Harshal Patil
  • 17,838
  • 14
  • 60
  • 126
1
vote
0 answers

Is it possible to nullify parent inside a GraphQL Resolver?

While optimizing my GraphQL resolvers, I have realized that resolving all the fields using their resolvers(not using the parent resolvers with some pre-filled data) is the way to utilize DataLoader in the most powerful way. Like this: export const…
anesin1109
  • 315
  • 3
  • 13
1
vote
2 answers

How to use Nexus' Prisma plugin crud with specific arguments

I have an Advertiser graphql type: type Advertiser { createdAt: DateTime! id: Int! isActive: Boolean! name: String! updatedAt: DateTime } Given the following mutation: mutationType({ definition(t) { t.crud.createOneAdvertiser(); …
Eliya Cohen
  • 10,716
  • 13
  • 59
  • 116
0
votes
0 answers

Nexusjs scalarType shows type error in Next.js project

I adopted scalarType (datetime) following the code from this question GraphQL Nexus asNexusMethod showing type error import { DateTimeResolver } from "graphql-scalars"; const DateTime = asNexusMethod(DateTimeResolver, "datetime"); const schema =…
Chayanin
  • 281
  • 1
  • 5
  • 11
0
votes
0 answers

Return fields by default in nexusJs Model

Return Status And Message Field as default fields without explicitly querying for both fields. Hi, I have been looking through stack overflow for answers but I was unable to find any. Here is my registration model: export const Register =…
Syed Huzaifa Hassan
  • 776
  • 1
  • 6
  • 22
1
2