Skip to content

A CLI tool for running the same GQL query repeatedly with variable values from a JSON file.

Notifications You must be signed in to change notification settings

LewdPursuits/gql-iterate

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📃 GQL-Iterate

A simple CLI utility for running a query repeatedly with different variable values supplied from a JSON file. Ever had to mass-query some object off GQL, but the server only supports fetching what you need one-by-one? That's what this is for!

🤓 Usage

Create a .gql file containing your query, which can be named anything (make sure there's only a single query specified in the file). Define the variables that you want gql-iterate to read from a JSON file with the usual syntax. For example:

mutation tagCreate($name: String!, $description: String, $aliases: [String!], $category: ID) {
  tagCreate(input: {name: $name, description: $description, aliases: $aliases, category_id: $category}) {
    id
    name
  }
}

Next, create your input JSON file, with matching variables. For example:

{"tags": [
	{
		"name": "test1",
		"description": "test1",
		"aliases": ["alias1"],
		"category": "7"
	},
	{
		"name": "test2",
		"description": "test2",
		"aliases": ["alias2"],
		"category": "7"
	}
]}

Now, it's time to run the queries! From the directory that contains your query and input JSON, run:

gql-iterate --host https://yourserver.com/graphql --input ./input.json --query ./query.gql

GQL-Iterate will now run all of your queries (this might take a while depending on the length of your input file and speed of your server) and print the output to console, as one stringified JSON object per line.

🗝 Authentication

GQL-iterate currently only supports ApiKey: Bearer Header-based auth. To supply a an API key, simply run the CLI with the --bearer < your key > option.

About

A CLI tool for running the same GQL query repeatedly with variable values from a JSON file.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%