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

Interface type safety #347

@janheinrichmerker

Description

@janheinrichmerker

Description

graphqlgen doesn't enforce type safety for type interfaces.

Steps to reproduce

Schema:

interface Availability {
	isAvailable: Boolean!
}
type EstimatedAvailability implements Availability {
	isAvailable: Boolean!
    timestamp: Int!
}
type RemainingAvailability implements Availability {
	isAvailable: Boolean!
    remainingItems: Int!
}
type Offer {
    availability: Availability!
}

Model classes:

export interface Availability {
	isAvailable: boolean
}
export interface EstimatedAvailability {
	isAvailable: boolean
	timestamp: number
}
export interface RemainingAvailability {
	isAvailable: boolean
	remainingItems: number
}
export interface Offer {
	availability: Availability
}

Expected results

export namespace OfferResolvers {

  export type AvailabilityResolver = (
    parent: Offer,
    args: {},
    ctx: Context,
    info: GraphQLResolveInfo
  ) => Availability | Promise<Availability>;

  export interface Type {
    availability: (
      parent: Offer,
      args: {},
      ctx: Context,
      info: GraphQLResolveInfo
    ) => Availability | Promise<Availability>;
  }
}

Actual results

export namespace OfferResolvers {

  export type AvailabilityResolver = (
    parent: Offer,
    args: {},
    ctx: Context,
    info: GraphQLResolveInfo
  ) => {} | Promise<{}>;

  export interface Type {
    availability: (
      parent: Offer,
      args: {},
      ctx: Context,
      info: GraphQLResolveInfo
    ) => {} | Promise<{}>;
  }
}

Versions

  • graphqlgen: 0.4.0
  • OS name and version: Node 8.11.2, NPM 6.4.1, Windows 10, 64 Bit

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions