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

Upgrade hooks api to use graphql-ppx 1.0 #225

Merged
merged 17 commits into from
Nov 8, 2020

Conversation

amiralies
Copy link
Contributor

@amiralies amiralies commented Nov 1, 2020

  • useQuery
  • useMutation
  • useSubscription
  • query examples
  • mutation examples
  • subscription examples

@amiralies amiralies marked this pull request as ready for review November 6, 2020 18:46
@parkerziegler parkerziegler self-requested a review November 7, 2020 01:03
@parkerziegler
Copy link
Contributor

Thanks for this @amiralies! I should be able to get to it this weekend and give a full review. Really appreciate you taking this on!

@@ -13,6 +13,7 @@
border-radius: 5px;
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
0 4px 6px -2px rgba(0, 0, 0, 0.05);
margin-top: 15rem;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for this? Mind posting a screenshot of the changes? It looks like you altered the structure of the HTML below as well, is there a compelling reason to do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dex is positioned in center of page (notice scroll position):

image

I think correct way to handle this is to use overflow-y: scroll on list.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated layout using flexbox

image

src/Types.re Outdated Show resolved Hide resolved
src/Types.re Outdated Show resolved Hide resolved
let useMutation:
type data variables.
(
~query: (module Types.Operation with
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd advocate for one of two options here:

  1. Rename this labelled argument to mutation.
Suggested change
~query: (module Types.Operation with
~mutation: (module Types.Operation with
  1. Don't bother with a labelled argument, since the hook only accepts a single argument.

1 is more compatible with the current API, while 2 maybe makes more sense from a language perspective. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both compiles to same js.
I actually like the first approach for consistency between APIs.
AFAIK there shoudn't be any problem with unary function with a (explicitly typed) labeled argument.
you can even omit label (though compiler gives a warning):

let (state, exec) = Hooks.useMutation((module MyMutation));

maybe @jfrolich can also help with this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it makes a difference. If you have multiple arguments it's good to have the query as the first argument because of type inference I think. Otherwise the variable record might not be inferred (not 100% sure).

type t = data and type t_variables = variables)
) =>
useMutationResponse(variables, data) =
(~query as (module Query)) => {
Copy link
Contributor

@parkerziegler parkerziegler Nov 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's name this locally like so:

Suggested change
(~query as (module Query)) => {
(~mutation as (module Mutation)) => {

Copy link
Contributor

@parkerziegler parkerziegler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great @amiralies, a huge, huge thank you for all of this work. A few comments that are mostly small stylistic suggestions, but the changes are very very close. Ping me again when you've addressed the comments, I'll review one last time, and then we can merge this puppy. Thanks again 💯

@amiralies
Copy link
Contributor Author

@parkerziegler I think this is ready to be reviewed again 🚀

Copy link
Contributor

@parkerziegler parkerziegler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful work @amiralies! Thank you again so much for moving this forward!

@parkerziegler parkerziegler merged commit e51d96f into teamwalnut:v3 Nov 8, 2020
@parkerziegler
Copy link
Contributor

@all-contributors please add @amiralies for code, example.

@allcontributors
Copy link
Contributor

@parkerziegler

I've put up a pull request to add @amiralies! 🎉

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

Successfully merging this pull request may close these issues.

3 participants