Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose makeVariables and makeMutation #33

Closed
jfrolich opened this issue Oct 30, 2019 · 3 comments · Fixed by #35
Closed

Expose makeVariables and makeMutation #33

jfrolich opened this issue Oct 30, 2019 · 3 comments · Fixed by #35
Labels
enhancement New feature or request

Comments

@jfrolich
Copy link
Collaborator

It would be great to have a bit more API surface to make a nicer API for consuming libraries. Sometimes you'd want to set up a mutation, and provide the variables dynamically. For instance with react-apollo a hook that returns a function that accepts variables. Because the make functions needs the variables, we cannot get back the data structure that includes the mutation itself and the parse function.
A workaround for now is to

  • pass the whole make function at the last moment and initially create an empty mutation in the hook.
  • Pass the query attribute and parse method to the hook and the variables attribute of make later.

Both not great options. I would propose a makeVariables function to make the variables data structure, and a makeMutation (better naming ideas?) that does the same thing as make but returns the data structure without variables. Any thoughts?

Happy to try to set up a PR for this, but interested in feedback on this first.

@jfrolich
Copy link
Collaborator Author

Related discussion in reason-apollo-hooks: reasonml-community/reason-apollo-hooks#59

@baransu
Copy link
Collaborator

baransu commented Oct 30, 2019

I think there is only a need to expose makeVariables function. make result is just a reexport or query and parse with created variables. You have access to query and parse all the time.

I think it should be fairly easy to implement. I'm open to PR 🙂 Let men know if you need some help.

@baransu baransu added the enhancement New feature or request label Nov 4, 2019
@jfrolich jfrolich mentioned this issue Nov 23, 2019
@baransu
Copy link
Collaborator

baransu commented Nov 23, 2019

Released in 0.3.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants