-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Description Inject variables into a query using a json file. ### Testing Instructions Added tests to `tests/query/variables.t`
- Loading branch information
1 parent
eae5582
commit ae18f26
Showing
3 changed files
with
66 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
Setup | ||
$ . ${TESTDIR}/../../../helpers/setup_integration_test.sh | ||
|
||
Create a variables file | ||
$ echo '{ "name": "my-app" }' > vars.json | ||
|
||
Query packages | ||
$ ${TURBO} query 'query($name: String) { package(name: $name) { name } }' --variables vars.json | jq | ||
WARNING query command is experimental and may change in the future | ||
{ | ||
"data": { | ||
"package": { | ||
"name": "my-app" | ||
} | ||
} | ||
} | ||
|
||
Write query to file | ||
$ echo 'query($name: String) { package(name: $name) { name } }' > query.gql | ||
|
||
Run the query | ||
$ ${TURBO} query query.gql --variables vars.json | jq | ||
WARNING query command is experimental and may change in the future | ||
{ | ||
"data": { | ||
"package": { | ||
"name": "my-app" | ||
} | ||
} | ||
} | ||
|
||
Make sure we can't pass variables without a query | ||
$ ${TURBO} query --variables vars.json | ||
ERROR the following required arguments were not provided: | ||
<QUERY> | ||
|
||
Usage: turbo(.exe)? query --variables <VARIABLES> <QUERY> (re) | ||
|
||
For more information, try '--help'. | ||
|
||
[1] | ||
|
||
|
||
|