Nexus-plugin-prisma: Can't get correct model types string

Created on 16 Oct 2019  路  5Comments  路  Source: graphql-nexus/nexus-plugin-prisma

Hi! I will try to be the most short as possible. Please could you warn me if it lacks information?

The error:
image
Only the initial scalars are being pulled, although there are more in my datamodel.

for example:
image
Does this proof I did generate correctly?

//src/index


import { GraphQLServer } from "graphql-yoga";
import { nexusPrismaPlugin } from "nexus-prisma";
import { makeSchema } from "nexus";
import * as allTypes from "./api";
import { join } from "path";
import { permissoes } from "./permissoes/index";
import { Photon } from "@generated/photon";

const photon = new Photon({ debug: true });

const nexusPrismaTypes = nexusPrismaPlugin({
  types: allTypes,
});

const schema = makeSchema({
  types: [allTypes, nexusPrismaTypes],
  typegenAutoConfig: {
    debug: true,
    sources: [
      {
        source: "@generated/photon",
        alias: "photon"
      },
      {
        source: join(__dirname, "types.ts"),
        alias: "ctx"
      }
    ],
    backingTypeMap: {
      Date: "Date",
      Upload: "Upload"
    },
    contextType: "ctx.Context"
  },
  outputs: {
    schema: join(__dirname, "./schema.graphql")
  }
});

export const server = new GraphQLServer({
  schema,
  // middlewares: [permissoes],
  context: request => ({
    ...request,
    photon
  })
});

server.start(() => console.log(`Server is running on http://localhost:4000`));

It appears to be no error when starting....

[INFO] 14:56:22 Restarting: manual restart from user
Using ts-node version 8.3.0, typescript version 3.4.5
Server is running on http://localhost:4000
  getos { platform: 'win32', libssl: undefined } +0ms
GraphQL Nexus: No match for Time in "@generated/photon" using /(?:interface|type|class|enum)\s+(Time)\W/g
GraphQL Nexus: No match for Time in "..\..\..\src\types" using /(?:interface|type|class|enum)\s+(Time)\W/g

How can I provide more info? Trying to solve this since yesterday, sorry if I missed something...

All 5 comments

Hey @outerlook, we just released a new version, you can look at docs & repo examples for details. Not sure yet what your issue is. I'm not super familiar with with the backingTypes system, and wonder if that could be related to your issue.

I think the reason why your output types are not appearing is that you're not calling the functions of t.crud., you're simply accessing them as properties, which does nothing.

Try the following for all t.crud/t.model (estados is just an example):

- t.crud.estados
+ t.crud.estados()

You're right, I missed that...

But still I can't make it work. It seems to miss the "type" argument.
image

Error: 
- Missing type CategoriaDeComodidade, did you forget to import a type to the root query or mean CategoriaDeComodidadeOrderByInput?
    at assertNoMissingTypes (C:\projetob\yugi\backend\node_modules\nexus\src\builder.ts:1663:11)
    at Object.makeSchema (C:\projetob\yugi\backend\node_modules\nexus\src\builder.ts:1589:3)
    at Object.<anonymous> (C:\projetob\yugi\backend\src\index.ts:11:16)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Module._compile (C:\projetob\yugi\backend\node_modules\source-map-support\source-map-support.js:521:25)
    at Module.m._compile (C:\Users\RAFFAE~2\AppData\Local\Temp\ts-node-dev-hook-5697630631774853.js:57:25)
    at Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at require.extensions.(anonymous function) (C:\Users\RAFFAE~2\AppData\Local\Temp\ts-node-dev-hook-5697630631774853.js:59:14)
    at Object.nodeDevHook [as .ts] (C:\projetob\yugi\backend\node_modules\ts-node-dev\lib\hook.js:61:7)
    at Module.load (internal/modules/cjs/loader.js:599:32)

When I look through @generated/photon files, it seems to be correctly generated, with all models I have on datamodel file.

I will try to reproduce the example on examples folder here.

Hi! I realized something I was missing.

Now I must first declare what models will be available on my api declaring it with t.model.MODEL, right? Sorry I didn't realize that before. I do have many models. Is there any easy way like t.prismaModels(['*']) or something to declare all at once?

without that, every time I want to add a new field to my model, I should update my schema.prisma file and then update also my model on nexus too, is it right?

following #299

Was this page helpful?
0 / 5 - 0 ratings

Related issues

franjohn21 picture franjohn21  路  4Comments

mihazs picture mihazs  路  4Comments

macrozone picture macrozone  路  3Comments

jasonkuhrt picture jasonkuhrt  路  4Comments

mohe2015 picture mohe2015  路  3Comments