Skip to content

Stitching: Automatically add required fields to queries? #242

@stuebingerb

Description

@stuebingerb

Consider a schema that links a local remoteId to a resolved remoteObject by calling fetchRemote:

type Local {
  id: String!
  remoteId: String!
  remoteObject: Remote
}

type Query {
  fetchLocal(id: String!): Local!
  fetchRemote(id: String!): Remote!
}

Currently, the local id always has to be part of the query, so the following query results in a null remoteObject:

query {
  fetchLocal(id: "foo") { id remoteObject }  // returns remoteObject as "null"
}

To get the remoteObject, the remoteId field has to be requested explicitly as well:

query {
  fetchLocal(id: "foo") { id remoteId remoteObject }  // returns proper remoteObject
}

Other libraries (looking at Atlassian Braid) manage to resolve the remote object either way, presumably by automatically adding the remoteId in such a case.

In a similar way, typed fragments always require the __typename to be present, which currently also has to be added manually.

To be discussed is whether this behavior should a) be implemented, b) be configurable, or c) only result in an explicit error message so that it is clear how the request needs to be adjusted to work as expected

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestinput wantedTarget solution is not yet clear or more input is wanted on an issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions