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

Find a good way to submit variables with a GraphQL query #5

Open
davazp opened this issue Oct 16, 2016 · 3 comments
Open

Find a good way to submit variables with a GraphQL query #5

davazp opened this issue Oct 16, 2016 · 3 comments
Labels

Comments

@davazp
Copy link
Owner

davazp commented Oct 16, 2016

GraphQL queries can contain variables that have to be sent separately. It would be useful to have a way to submit the variable values.

Look at https://github.com/graphql/graphiql for some examples.

@davazp davazp added the feature label Oct 16, 2016
@timoweave
Copy link
Collaborator

I believe the branch "next" is for this feature.

@TOTBWF
Copy link
Contributor

TOTBWF commented Oct 17, 2019

I've been thinking about this a bit recently, and have come across the following solution:

query Foo {
  bar {
    fizz
    baz {
      quux
    }
  }
}

#$var1 : ?bar.fizz
#$var2 : 4

mutation Blorp($var1 : String!, $var2 : Int) {
...
}

Here the ?bar.fizz refers to the result of the previous query. In general, any ? binder would refer to the query directly above it.

This has a few nice benefits:

  1. The files remain valid .graphql files.
  2. You can do variable capturing from previous queries, which is a very common workflow.

I'll look into getting a POC working in the next few days, though a few features need to be added 1st (multiple queries mainly).

@davazp
Copy link
Owner Author

davazp commented Oct 18, 2019

Those are nice but it seems more a language on top of GraphQL. Nothing wrong with that, but maybe it should be built on top of grapqhl-mode rather than in it I feel.

I think having a separate buffer for managing bars like GraphIQL is probably the way to go. I see making this mode more "IDE"-like better than a language-like.

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

No branches or pull requests

3 participants