Skip to content

Apollo-Compiler Feature Request: Schema Type Merging #961

Open
@samtipton

Description

@samtipton

Description

Type merging is a highly desirable feature in gateway systems or in highly modularized graphql projects that want to present a coherent public schema.

Type merging means collecting extension objects fields and directives back into the base type for all types in the AST for non-executable documents.

This is supported in library such as graphql-java and apollo-kotlin.

Please describe in as much detail the kind of feature would you like us to add!

Add details like:

  • What does it do?

Merges all extension objects fields into the base type for all types in the AST. That is, takes the fields and directives from each extension and mutates them into the type the extension is extending

type User {
    id: ID!
    name: String!
}

extend type User {
    email: String
}

After merging we would get

type User {
    id: ID!
    name: String!
    email: String
}
  • What are the inputs/outputs?
    document in, document out.

  • An API sketch

    Document::to_merged(&document)

    // or perhaps
    Document::parser().parse_into_merged(&schema)
    Document::parser().parse_into_merged(&schema_builder)

Document#toMergedGQLDocument

  • What is your use case for this?
    Stitching federated subgraph schemas together for public use and not wanting extensions defined through public api contract while allowing developers freedom to split up schema definitions files

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions