dotansimha / dotansimha/graphql-code-generator

Generate types for interfaces without any implementing types

Open
#3,982 2 comments 4 reactions 1 assignee Claimed by @ardatan View on GitHub
core dependencies stage/1-reproduction
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

**Is your feature request related to a problem? Please describe.**
I have a statically-known portion of my schema including an `interface Node` that I would like to generate types for: when my app starts, I `fetch` a remote jsonschema and translate that into multiple type definitions that implement said `interface Node` which I attach to the schema and start the server.

Currently, interfaces without implementations don't seem to generate anything.
It also seems that concrete types where all fields are of a type of an unimplemented interface are completely omitted.

**Describe the solution you'd like**
I would like an option to generate a type for an interface that consists of the fields of that interface instead of a union of all of the implementations.

**Describe alternatives you've considered**
I tried creating a dummy type that implements this interface but I don't want to pollute my sever with types like this.

I also am using a custom plugin and it seems that the schema that I get as an argument doesn't even have unimplemented interfaces listed anywhere in the `GraphQLSchema` so this problem may be higher up.

**Additional context**
Go to the demo and paste this schema:
https://graphql-code-generator.com/#live-demo
```graphql
schema {
query: Query
mutation: Mutation
}

type Query {
with_impl: IFoo
zero_impl: IBar
}

type Mutation {
zero_impl: IBar
}

interface IFoo {
foo: String!
}

interface IBar {
bar: String!
}

type Foo implements IFoo {
foo: String!
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.