Skip to content

Context type merging conflicts are confusing #1303

@jasonkuhrt

Description

@jasonkuhrt

Perceived Problem

  • https://github.com/graphql-nexus/nexus/pull/1295#discussion_r461447486
  • we use declaration merging to merge different context contributions
  • if any fields overlap but have different types there will be a hard TS error
  • if developer is the overrider but doesn't know about the pre-existnig type he may be confused about what is going on
  • if the developer provided the existing type but a plugin overrides he/she may be confused about what is going on
  • if developer did nothing, but two plugins collide, he/she may be even more confused about what is going on

Ideas / Proposed Solution(s)

  • clear feedback when collisions happen

    1. Where did the current entry come from?
    2. Where dit the new conflicting entry come from?
  • if we want to allow runtime to do context entry overwriting (not deep merging but literally wipe out the previous value) then we need a custom type merge instead of relying on declaration merging

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