All Projects → opentable → graphql-query-generator

opentable / graphql-query-generator

Licence: other
Generates queries from the GraphQL endpoint via schema introspection.

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to graphql-query-generator

Htmltestrunner
A Test Runner in python, for Human Readable HTML Reports
Stars: ✭ 228 (+365.31%)
Mutual labels:  testing-tools
Database cleaner
Strategies for cleaning databases in Ruby. Can be used to ensure a clean state for testing.
Stars: ✭ 2,750 (+5512.24%)
Mutual labels:  testing-tools
allure-nunit
Archived - Allure adapter for NUnit framework.
Stars: ✭ 45 (-8.16%)
Mutual labels:  testing-tools
Mockito Scala
Mockito for Scala language
Stars: ✭ 231 (+371.43%)
Mutual labels:  testing-tools
Kotlin Compile Testing
A library for testing Kotlin and Java annotation processors, compiler plugins and code generation
Stars: ✭ 245 (+400%)
Mutual labels:  testing-tools
Pywinauto
Windows GUI Automation with Python (based on text properties)
Stars: ✭ 3,175 (+6379.59%)
Mutual labels:  testing-tools
Junit Dataprovider
A TestNG like dataprovider runner for JUnit with many additional features
Stars: ✭ 226 (+361.22%)
Mutual labels:  testing-tools
go-smtp-mock
SMTP mock server written on Golang. Mimic any 📤 SMTP server behavior for your test environment with fake SMTP server.
Stars: ✭ 76 (+55.1%)
Mutual labels:  testing-tools
Diffx
Pretty diffs for scala case classes
Stars: ✭ 250 (+410.2%)
Mutual labels:  testing-tools
vision-ui
视觉UI分析工具
Stars: ✭ 165 (+236.73%)
Mutual labels:  testing-tools
Swaks
Swaks - Swiss Army Knife for SMTP
Stars: ✭ 239 (+387.76%)
Mutual labels:  testing-tools
Dinghy
Easier cross-compilation for phones and single boards computers
Stars: ✭ 241 (+391.84%)
Mutual labels:  testing-tools
kentan
A modular test data generator for TypeScript
Stars: ✭ 38 (-22.45%)
Mutual labels:  testing-tools
Testrocket
Super simple Ruby testing library
Stars: ✭ 229 (+367.35%)
Mutual labels:  testing-tools
phptt
phptt a.k.a php test tools
Stars: ✭ 15 (-69.39%)
Mutual labels:  testing-tools
Goreplay
As your application grows, the effort required to test it also grows exponentially. GoReplay offers you the simple idea of reusing your existing traffic for testing, which makes it incredibly powerful. Our state of art technique allows you to analyze and record your application traffic without affecting it. This eliminates the risks that come with putting a third party component in the critical path.
Stars: ✭ 14,981 (+30473.47%)
Mutual labels:  testing-tools
Taiko
A node.js library for testing modern web applications
Stars: ✭ 2,964 (+5948.98%)
Mutual labels:  testing-tools
rtl-simple-queries
Simple wrapper queries for @testing-library/react
Stars: ✭ 20 (-59.18%)
Mutual labels:  testing-tools
bibop
Utility for testing command-line tools, daemons, and packages
Stars: ✭ 17 (-65.31%)
Mutual labels:  testing-tools
fluttertest
Custom flutter testing CLI tool for individual test runs and group testing
Stars: ✭ 15 (-69.39%)
Mutual labels:  testing-tools

build

This repo is no longer maintained. Feel free to fork and enjoy it, but no further development is anticipated.

GraphQL Query Generator

GraphQL Query Generator is a library/tool that helps you easily test your GraphQL endpoints using introspection!

Getting Started

So you want to test your GraphQL endpoint. This tool will generate all the queries that your GraphQL endpoint will have. However, for queries that require parameters, this tool will need annotations. So please follow the steps below to get started.

1. Annotate your queries (optional, although highly recommended):

Create example queries that you want tested in the comments!

type Query {
  # RollDice has four examples
  #
  # Examples:
  # rollDice(numDice: 4, numSides: 2)
  # rollDice( numDice : 40 , numSides:2)
  # rollDice ( numDice: 2, numSides: 299 )
  # rollDice (
  #   numDice:4,
  #   numSides: 2342
  # )
  rollDice(numDice: Int!, numSides: Int): RandomDie
}

2 Run the tool!

You can use either the CLI or the library to get started!

2.1 Using the CLI

Execute following commands to get this tool running.

NOTE: Whenever there are parameters required you need to provide them in Graphql schema by following our Examples notation. You can find it in Usage section.

npm i -g graphql-query-generator
gql-test http://<your-server-address>:<your-server-port>
gql-test --help # for more information

2.2 Using the library

If you want more control over the queries that are generated via this tool. Please see the following example:

const QueryGenerator = require('graphql-query-generator');
const request = require('request');
const assert = require('assert');

describe('Query generation', function() {
  const serverUrl = 'http://<your-server-address>:<your-server-port>/graphql';
  let queries = null;

  before(() => {
    const queryGenerator = new QueryGenerator(serverUrl);
    queryPromise = queryGenerator.run();
  });

  it('Generates multiple queries', function() {
    this.timeout = 50000;

    return queryPromise
      .then(({queries, coverage}) =>{
          console.log(`Coverage: ${coverage.coverageRatio}`);
          console.log(`skipped fields: ${coverage.notCoveredFields}`);
          return Promise.all(queries.map(query => requestToGraphQL(serverUrl, query)));
      })
      .then(results => assert.equal(results.filter(x => x.statusCode !== 200).length, 0));
  });
});

function requestToGraphQL(serverUrl, query) {
  return new Promise((resolve, reject) => {
    request(serverUrl, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json'
      },
      body:JSON.stringify({
        "query": query,
        "variables": "{}",
        "operationName": null
      })
    }, function (err, result) {
      if (err) return reject(err);

      resolve(result)
    });
  });
}

This is an example of a test that will just check that it returns HTTP status code 200! It would be also good to check if, say, the body contains an error section. However, it's all up to you!

Extras

Opt out of certain queries

When annotating, if you add +NOFOLLOW in examples will prevent this path from being followed when creating queries

type RandomDie {
  numSides: Int!
  rollOnce: Int!
  statistics(page: Int!): RandomnessStatistics!

  # A description for ignored field with parameters
  #
  # Examples:
  # ignoredWithExamples(parameter: 42)
  # +NOFOLLOW
  ignoredWithExamples(parameter: Int!): IgnoredSubtype

  # +NOFOLLOW
  ignoredNoParameters: IgnoredSubtype
}

Contributing

We welcome feedback! Please create an issue for feedback or issues. If you would like to contribute, open a PR and let's start talking!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].