![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
graphql-monkey
Advanced tools
A test framework and CLI for running fully automated, randomized tests against any GraphQL API.
:monkey: A test framework and CLI for running fully automated, randomized tests against any GraphQL API.
npm i graphql-monkey -g
Testing a GraphQL API directly via command-line:
gqlm --url https://countries.trevorblades.com
See gqlm --help
for more options.
Most use cases will need an options file with some preparation logic (authentication etc., see below for a detailed reference). For example:
const request = require('request-promise-native');
module.exports = { gqlm };
async function gqlm() {
return {
url: 'https://graphql.example.com',
count: 30,
requestOptions: await login()
};
}
async function login() {
const response = await request({
method: 'POST',
url: 'https://oauth.example.com',
body: {
grant_type: 'password',
client_id: 'xxxxx',
client_secret: 'xxxxx',
username: 'gibbon',
password: 'bananas'
},
json: true
});
return {
headers: {
Authorization: `Bearer ${response.access_token}`
}
};
}
Run with gqlm example.js
.
Options may be set using an options file.
An options file is a JavaScript file exporting
a default function or gqlm
function
returning an object containing the options.
The exported function may be async.
For TypeScript there's a TestOptionsInput
interface
which may be used as a return type.
Using the options file, you can implement preparation logic, like authentication.
Additionally, some options may be set via command-line.
count: number
Sets the number of queries to generate and test.
exit: boolean
If set, GQLM will exit after the first failed request. Useful to fix failures step-by-step.
Defines what GQLM will print to the console. Multiple arguments may be specified. Possible values are:
requests
: Print requestsresponses
: Print responseserrors
: Print GraphQL errorsfailures
: Print requests and GraphQL errors for failed testsmemory
: Print memory after all teststypes
: Print a report for each type, including coverageFor example, gqlm example.ts -p failures -p memory
will print failures and
the data in memory after all tests.
Requires a Node.js module on startup. Multiple modules may be specified.
Useful for transpilation, e.g when using TypeScript:
gqlm example.ts --require ts-node/register
seed: string
Sets the seed for random number generation.
Setting the seed yields a deterministic, reproducible run of tests. Useful to reproduce failures during development.
The seed of the last run is printed at the end of every report.
data: any
Sets the initially known data for argument generation. The provided data may have any structure.
When generating arguments, GQLM will match argument names to keys in its knowledge base, and prefer using known values to guess arguments.
The knowledge is built from the given initial data as well as from recorded response bodies.
For example, if the GraphQL API has arguments or inputs named fruit
anywhere,
GQLM can be "helped" to guess input for these fields by providing:
function gqlm() {
return {
// ...
data: {
fruit: ['banana', 'apple', '...'],
// ...
}
}
}
aliases: string[][]
Defines aliasing for data. Often, different field names have the same semantics,
for example Customer.id
may be equivalent to Contract.customerId
.
GQLM will use aliases to match field names and known data more effectively.
{
aliases: [
["id", "customerId", "contractId"],
/*...*/
]
}
requestOptions: request.Options
Options for HTTP requests. See https://www.npmjs.com/package/request-promise
endpointCallback: (endpoint: TestEndpoint) => TestEndpoint | null
An optional callback that allows transforming (return endpoint) or omitting test endpoints (return null).
errorCallback: (error: GraphQLError) => boolean
An optional callback that determines whether an error is an unexpected error (return true) or not (return false).
Only unexpected errors will mark a test result as failed.
resultCallback: (result: TestResult) => TestResult | null
An optional callback that allows transforming (return result) or omitting test results (return null).
FAQs
A test framework and CLI for running fully automated, randomized tests against any GraphQL API.
We found that graphql-monkey demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.