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

Allow using import in model files #473

@Yuyz0112

Description

@Yuyz0112

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions