Prisma 2 query relation return null

1.3k views Asked by At

I migrated my project from prisma 1. Then I added new models relative to my Live model. I try to query the new models with relation type (one-to-one and one-to-many) but that returns null.

Here is my prisma.schema

enter image description here

Query live.questionnaire{} works but questionnaire.live{} doesn't, and both questionnaire.questionnaireField{} and questionnaireField.questionnaire{} dont't wortk.

Here is an exemple of the playground

live.questionnaire is ok. enter image description here

questionnaire.live is not.

My schemas

Live schema perview where relation live.questionnaire ok

Each of questionnaire.live and questionnaire.fields and questionnaireField.questionnaire are down enter image description here

My query resolver where only createdAt works

enter image description here In prisma studio everything seems to be good...

If someone could help, Thanks

1

There are 1 answers

2
Ahmed Elywa On

See your resolvers not clear but I will give you a way to build your GraphQL server with Prisma in just minute using Pal.Js CLI you can start new project with my CLI and just put your schema and run one command pal g and you will get everything ready for you with full CRUD system.

Install my CLI

yarn global add @paljs/cli
//or
npm install -g @paljs/cli

Start new project

> pal c


.______      ___       __             __       _______.
|   _  \    /   \     |  |           |  |     /       |
|  |_)  |  /  ^  \    |  |           |  |    |   (----`
|   ___/  /  /_\  \   |  |     .--.  |  |     \   \
|  |     /  _____  \  |  `----.|  `--'  | .----)   |
| _|    /__/     \__\ |_______| \______/  |_______/

✔ Please select your start example · apollo-sdl-first
  full-stack-nextjs
  full-stack-gatsbyjs
  apollo-nexus-schema
❯ apollo-sdl-first // select this example
  graphql-modules

✔ please enter your project name · great-project
✔ please enter your project description · new NodeJs Prisma GraphQL TypeScript project
✔ please enter your project author · Ahmed Elywa
✔ please enter your project repository · https://github.com/paljs/prisma-tools
✔ please select your package manager · yarn
❯ yarn
  npm

✔ Skip package installation · no
❯ yes
  no

Now open your project folder and change ./prisam/schema.prisma file with yours

now generate all resolvers

pal g

you have now your graphql server ready

start your server

yarn dev
or
npm run dev

that is it