Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

Enums in prisma generated file are not being picked up #197

Closed
herkulano opened this issue Oct 26, 2018 · 5 comments
Closed

Enums in prisma generated file are not being picked up #197

herkulano opened this issue Oct 26, 2018 · 5 comments

Comments

@herkulano
Copy link

Description

Enums in prisma generated file are not being picked up. My understanding is that it should also pick them from the prisma generated files and generate them for the resolvers as typescript enums.

Steps to reproduce

Add a PostType enum to the example https://github.com/prisma/prisma-examples/tree/master/typescript-graphql-auth

./prisma/enums.graphql

enum PostType {
  MESSAGE
  ANNOUNCEMENT
  RANDOM
}

./prisma/prisma.yml

endpoint: http://localhost:4466
datamodel: 
  - datamodel.prisma
  - enums.graphql
generate:
    - generator: typescript-client
      output: ../src/generated/prisma-client/

Generate prisma files

$ prisma generate

Import enum in schema.graphql

# import * from '../prisma/enums.graphql'

Run

$ graphqlgen

Expected results

Resolvers and enums are generated without errors

Actual results

❌ Some types from your application schema have model definitions that are not defined yet

Step 1: Copy/paste the model definitions below to your application

export interface PostType {

}


Step 2: Reference the model definitions in your graphqlgen.yml file

models:
  files:
    - ./path/to/your/file.ts

Step 3: Re-run `graphqlgen`

Versions

  • graphqlgen: 0.2.12
  • OS name and version: MacOS 10.14
@Weakky
Copy link
Contributor

Weakky commented Oct 26, 2018

Hey there,

Could you please provide us your graphqlgen.yml configuration file?

Thanks

@herkulano
Copy link
Author

herkulano commented Oct 26, 2018

graphqlgen.yml:

# The target programming language for the generated code
language: typescript

# The file path pointing to your GraphQL schema
schema: ./src/schema.graphql

# Type definition for the resolver context object
context: ./src/types.ts:Context

# Map SDL types from the GraphQL schema to TS models
models:
  files:
    - path: ./src/generated/prisma-client
      defaultName: '${typeName}Node'
    - ./src/types.ts

# Generated typings for resolvers and default resolver implementations
# Please don't edit this file but just import from here
output: ./src/generated/graphqlgen.ts

# Temporary scaffolded resolvers to copy and paste in your application
resolver-scaffolding:
  output: ./src/generated/tmp-resolvers/
  layout: file-per-type

@victory1908
Copy link

victory1908 commented Oct 27, 2018

I'm having the same problem. Anyway to deal with enum? it might because of this

defaultName: '${typeName}Node'

enum does not have Node

@arielschiavoni
Copy link

I am also having the same problem with enums. More info here

@schickling
Copy link
Contributor

This will be fixed with #244

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants