36

GraphQL Query Generator Library by IBM

 3 years ago
source link: https://blog.graphqleditor.com/graphql-query-generator/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

GraphQL Query Generator is an interesting library brought to you by the IBM team, which’s the main idea is to allow users to generate randomized GraphQL queries from any given GraphQL schema.

The first thought that comes to your mind might be:

“Why I may ever want a bunch of randomized queries?”

but giving it a second thought it might be quite useful. The team behind the GraphQL Query Generator suggested two basic use-cases for their library:

  • Engineering- when operating a GraphQL service you might find this library useful for:

    • developing a collection of test modules of GraphQL queries,
    • developing a test group of queries to check the effect of performance improvements,
  • Scientific - to learn about the characteristics of various GraphQL services.

Queries generation

The library provides two functions for generating random GraphQL queries, both expecting a GraphQL schema, as well as specific instructions provided in configuration object as an input:

getRandomQuery(schema: GraphQLSchema, config: Configuration)
getRandomMutation(schema: GraphQLSchema, config: Configuration)

graphql_query_generator_diagram.png

Source: github.com/IBM

The configuration object accepts a set of predefined properties i.e.:

maxDepth
argumentsToIgnore
considerInterfaces
considerUnions

The full list of available properties is available in the GraphQL Query Generator docs .

Sample GraphQL Query Generator configuration object

sample_configuration.png

Source: github.com/IBM/graphql-query-generator

Great addition

GraphQL Query Generator is a great addition to the already broad spectrum of GraphQL tools. Its a relatively new library that is worth experimenting with as maybe you could find some other innovative ways it could be used by the GraphQL community.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK