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

Add support to append entire field #5

Open
tlvenn opened this issue Sep 21, 2015 · 2 comments
Open

Add support to append entire field #5

tlvenn opened this issue Sep 21, 2015 · 2 comments

Comments

@tlvenn
Copy link
Contributor

tlvenn commented Sep 21, 2015

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 ?

@tlvenn
Copy link
Contributor Author

tlvenn commented Sep 21, 2015

Example of schema using graphql-relay-js: https://github.com/facebook/relay/blob/master/examples/todo/data/schema.js

tlvenn pushed a commit to tlvenn/graphql-schema that referenced this issue Sep 22, 2015
@tlvenn
Copy link
Contributor Author

tlvenn commented Oct 5, 2015

@devknoll any comment ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant