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

Get the query's name (string) for usage in Apollo's refetchQueries #83

Open
elnygren opened this issue Jun 25, 2019 · 1 comment
Open

Comments

@elnygren
Copy link

Could graphql_ppx generate a let binding that contains the GraphQL query's name?

example input

module FooBarGQL = [%graphql
  {|
  query fooBarDingDong {
    foo { bar }
  }
|}
];

output:

module FooBarGQL = {
  /* all the usual fields  generated by graphql_ppx */
  let ppx_printed_query = "...";
  let query = ppx_printed_query;
  let parse = value...;
  // ...etc...

  /* new field */
  let queryName = "fooBarDingDong"
}

This would be nice as now we have to do refetchQueries=[| "fooBarDingDong" |] https://github.com/apollographql/reason-apollo#mutation

@baransu
Copy link
Contributor

baransu commented Oct 5, 2019

reason-apollo-hooks uses the approach with passing both query and variables as it's supported by Apollo. Probably a good idea to submit PR to reason-apollo to support such a way of passing refetchQueries

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

No branches or pull requests

2 participants