Skip to content

Why are Graphql Types converted into interfaces ? #103

@jwickens

Description

@jwickens

Here's a snippet from one of my flow exports

flowtypes.js

  export type AnalyticsSetResult = IConversationMetricResult | IBotUpdateMetricResult;

  export interface IAnalyticsSetResult = {
    __typename: "AnalyticsSetResult";
    id: string;
    sets: Array<AnalyticsSet> | null;
}

schema.graphql

interface AnalyticsSetResult {
  id: ID!
  sets: [AnalyticsSet]
}

type ConversationMetricResult implements AnalyticsSetResult {
  id: ID!
  sets: [ConversationMetricSet]
}

I can sort of see why this decision was made - you wanted a concrete type with the name of the interface that is a union of all the types implementing that interface. So to get around that you moved all graphql types to be interfaces and only generate types for these unions. It seems unnecessary and its confusing to have different names between code types and graphql 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