A little tool which helps querying and automatically does the paging fo you
- To use it, copy the binary for your OS from the bin folder to some place you like.
- Create a file named
config.json
in the same folder. It should look like this:
{
"graphQlUrl": "https://graphql.example.com",
"companyId": 1,
"auth": {
"authemail": "user@shyftplan.com",
"authtoken": "sHyFtPlAnLoGiNtOkEn"
}
}
- Replace the url, the companyId and the authentication fields with the values you want to use.
- Create a file called
query.gql
in the same folder You can then write the paged query you want to run. It should look similar to this
query (
$companyId: Int!
$perPage: Int = 200
$page: Int = 1
) {
employments(
companyId: $companyId,
perPage: $perPage,
page: $page,
) {
id
firstName
lastName
}
}
The naming for companyId
, perPage
and page
has to be exactly like here. (Check if the endpoint you want to query supports this filters)
- now you can run the query by opening a terminal in this folder and running
./index-[your os]
. If everything worked fine, you'll seeThe file was saved!
, and there'll be a file created named like the endpoint you queried + .json. (Would beemployments.json
for the upper example).
You can add other filters to the query, like following:
settings.json
"graphQlParams": {
"fieldToQuery": "queryValue"
}
query.gql
query(
# [...]
$fieldToQuery: String
# [...]
) {
employments(
# [...]
fieldToQuery: $fieldToQuery
# [...]
) {
# [...]
}
}
To export a *.csv
file instead of a *.json
file, just add "outputType": "csv"
to your settings.json. Right now json
and csv
are the only supported settings.