Skip to content

Conversation

jeddeloh
Copy link
Owner

@jeddeloh jeddeloh commented Jul 23, 2020

This is a companion PR for teamwalnut/graphql-ppx#175.

That PR makes it possible for hooks and client methods now accept t_variables instead of Raw.t_variables. The advantage of this is that records can be the primary way of passing variables and makeVariables is a convenience function for when you want to only pass a few optional variables. Using Raw. t_variables before allowed you to explicitly pass null arguments, however. To accommodate this, you can now pass a mapNullVariables (name?) function to anything that takes t_variables. Something like this:

  let queryResult = ExampleQuery.use(
    ~mapNullVariables=(jsVars => {
      ...jsVars,
      explicitNullableArg: Js.Nullable.null
    }),
    {id: "1": explicitNullableArg: None}
  );

I'm only really concerned with being able to pass t_variables at the call site, so everywhere else things are typed as Raw.t_variables. I think that's fine and perhaps even preferable in some cases.

@jfrolich
Copy link
Collaborator

jfrolich commented Jul 24, 2020

Ah that's nifty! Maybe just mapRawVariables?

@jfrolich
Copy link
Collaborator

Wanna pull the trigger on this?

@jeddeloh
Copy link
Owner Author

Ah that's nifty! Maybe just mapRawVariables?

That feels more accurate. What about mapJsVariables? I've avoided raw in favor of Js in the types 🤷

@jeddeloh
Copy link
Owner Author

jeddeloh commented Jul 24, 2020

Wanna pull the trigger on this?

Let's do it!

@jfrolich
Copy link
Collaborator

That feels more accurate. What about mapJsVariables? I've avoided raw in favor of Js in the types 🤷

Yes, sure

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.

2 participants