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

Allow using import in model files #473

Open
Yuyz0112 opened this issue Apr 4, 2019 · 0 comments
Open

Allow using import in model files #473

Yuyz0112 opened this issue Apr 4, 2019 · 0 comments

Comments

@Yuyz0112
Copy link

Yuyz0112 commented Apr 4, 2019

Description

Currently, I found we could not use types imported from other files in the model file. For example, if I have two typescript files like this:

// types.ts
export type A = 'A' | 'a'
// models.ts
import { A } from './types.ts'

export interface Entity {
  a: A
}

If trying to generate this model file, graphqlgen will throw an error about TypeError: Cannot read property 'kind' of undefined.
After some debugging, I found this is because of graphqlgen cannot build type getter for the imported type A.

I have seen something like filesToTypesMap and addFileToTypesMap are related to this, but looks like they are used for testing. So is it possible to have this kind of import working?

Additional context

I think this is useful when using graphqlgen with Prisma because Prisma will generate types according to the enums in the datamodel. And custom models may use this enum which needs to import types from the generated Prisma client types.

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

1 participant