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

Generate type for variables #19

Open
janicduplessis opened this issue Feb 1, 2018 · 1 comment
Open

Generate type for variables #19

janicduplessis opened this issue Feb 1, 2018 · 1 comment

Comments

@janicduplessis
Copy link

janicduplessis commented Feb 1, 2018

I'm trying to improve the apollo graphql client to use a functor module to create a query fetching component and the last piece missing is the type of the variables of the query, similar to the one added for the return type.

The api I'm going for would look like:

module AppQuery = [%graphql {| ... |}];

module QueryRenderer = Client.Query.Create(AppQuery);

<QueryRenderer variables={"a": a}>...</Query>

This would allow to type the variables prop easily.

@anmonteiro
Copy link
Contributor

Just ran into this too.

solved it by nesting my mutation in the module I pass as argument to the functor like below:

module type MutationType = {
  type t;
  type variables;

  module Mutation: {
    let makeWithVariables:
      variables =>
      {
        .
        "parse": Js.Json.t => t,
        "query": string,
        "variables": Js.Json.t,
      };
  };
};

ylecornec pushed a commit to o1-labs/graphql_ppx that referenced this issue Jun 3, 2022
…tion

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

No branches or pull requests

3 participants