1

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

J.dev
  • 844
  • 3
  • 12
  • 22
  • Can you add a live model preview in your schema screenshot? Also, the two screenshots from the playground see the same thing – Ahmed Elywa Oct 09 '20 at 14:48
  • Thank you for your comment, I have updated the playground screenshots and the live model preview is just below the playgrounds – J.dev Oct 09 '20 at 15:11
  • There is no issue in your codes. Try to get a questionnaire.live by the same id in the first playground query. Also, try to use your code on a new empty DB maybe you have an issue in your first DB from upgrading from Prisma 1 to Prisma 2 If you can replicate your issue in a GitHub repo with a simple code, not all your project will be very helpful to find the issue with you – Ahmed Elywa Oct 09 '20 at 16:45

1 Answers1

0

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

Ahmed Elywa
  • 439
  • 3
  • 7
  • Thank you for your answer, but the project is already in production, and 20 others models work fine, the problem happens when I want to add the questionnaire and other s new models relative to the live model... – J.dev Oct 09 '20 at 12:49
  • Yes, and what I say to you that you can make an example project with my setup and if you don't get the issue with my setup so you can compare and know where is the issue. – Ahmed Elywa Oct 09 '20 at 14:38