Skip to content
This repository was archived by the owner on Feb 10, 2022. It is now read-only.
This repository was archived by the owner on Feb 10, 2022. It is now read-only.

Add support to append entire field #5

@tlvenn

Description

@tlvenn

In order to be friendly with Relay and graphql-relay-js lib, the API needs to allow the user to append some fields directly to an Object or an Interface.

Example would be to use the globalIdField or the mutationWithClientMutationId helpers from graphql-relay-js.

I was tempted to hack the field method but then it breaks the promise that it's a field you can build on (add some args and define the resolve method) because the passed object literal define all of those already.

I suspect to avoid any confusion, we should have an explicit method to handle this.
May be appendField(name:String,field:Object) and it would do :

appendField(name,field) {
 this.__saveField();

 invariant(
      !this.fields[name],
      `appendField(...): '${name}' is already defined`
    );

  this.fields[name] = field;
}

What do you think ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions