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

fix: unable to use variable as graphql input #421

Merged
merged 2 commits into from
Mar 23, 2023
Merged

Conversation

yanghua-ola
Copy link
Contributor

@yanghua-ola yanghua-ola commented Mar 23, 2023

This PR add the ability to use variable as GraphQL query variables, e.g.

{{
  exports.variables = {
    "limit": 10
  };
}}

POST  http://localhost:7002/graphql

query launchesQuery($limit: Int!){
  launchesPast(limit: $limit) {
    mission_name
  }
}

{{ variables }}

OR

{{
  exports.variables = {
    "foo": 10,
    "bar": 20
  };
}}

POST  http://localhost:7002/graphql

query launchesQuery($limit: ComplexInput!){
  launchesPast(limit: $limit) {
    mission_name
  }
}

{
  "limit": {{ variables }}
}

Above requests raise exception in current version, because JSON.parse was hooked on execute event, which happens before variable replacement.

@yanghua-ola
Copy link
Contributor Author

Wait, just noticed it broke for loop

@yanghua-ola
Copy link
Contributor Author

Wait, just noticed it broke for loop

fixed

@AnWeber AnWeber merged commit 7b8afd6 into AnWeber:main Mar 23, 2023
@AnWeber
Copy link
Owner

AnWeber commented Mar 23, 2023

Yes makes sense to parse it only after the variable substitution. Thanks for the improvement.

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