Gathering detailed insights and metrics for wd-gql-generator
Gathering detailed insights and metrics for wd-gql-generator
Gathering detailed insights and metrics for wd-gql-generator
Gathering detailed insights and metrics for wd-gql-generator
Generate queries from graphql schema, used for writing api test.
npm install wd-gql-generator
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
382 Stars
55 Commits
93 Forks
10 Watchers
2 Branches
16 Contributors
Updated on Jun 19, 2025
Latest Version
1.0.3
Package Id
wd-gql-generator@1.0.3
Unpacked Size
24.32 kB
Size
7.07 kB
File Count
11
NPM Version
8.19.2
Node Version
16.18.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
5
Generate queries from graphql schema, used for writing api test.
1# Sample schema 2type Query { 3 user(id: Int!): User! 4} 5 6type User { 7 id: Int! 8 username: String! 9 email: String! 10 createdAt: String! 11}
1# Sample query generated 2query user($id: Int!) { 3 user(id: $id){ 4 id 5 username 6 email 7 createdAt 8 } 9}
1# Install 2npm install gql-generator -g 3 4# see the usage 5gqlg --help 6 7# Generate sample queries from schema file 8gqlg --schemaFilePath ./example/sampleTypeDef.graphql --destDirPath ./example/output --depthLimit 5
Now the queries generated from the sampleTypeDef.graphql
can be found in the destDir: ./example/output
.
This tool generate 3 folders holding the queries: mutations, queries and subscriptions. And also index.js
files to export the queries in each folder.
You can require the queries like this:
1// require all the queries 2const queries = require('./example/output'); 3// require mutations only 4const mutations = require('./example/output/mutations'); 5 6// sample content 7console.log(queries.mutations.signup); 8console.log(mutations.signup); 9/* 10mutation signup($username: String!, email: String!, password: String!){ 11 signup(username: $username, email: $email, password: $password){ 12 token 13 user { 14 id 15 username 16 email 17 createdAt 18 } 19 } 20} 21*/ 22
The tool will automatically exclude any @deprecated
schema fields (see more on schema directives here). To change this behavior to include deprecated fields you can use the includeDeprecatedFields
flag when running the tool, e.g. gqlg --includeDeprecatedFields
.
Alternatively, you can run gql-generator
directly from your scripts:
1const gqlg = require('gql-generator') 2 3gqlg({ schemaFilePath: './example/sampleTypeDef.graphql', destDirPath: './example/output', depthLimit: 5 })
Say you have a graphql schema like this:
1type Mutation { 2 signup( 3 email: String! 4 username: String! 5 password: String! 6 ): UserToken! 7} 8 9type UserToken { 10 token: String! 11 user: User! 12} 13 14type User { 15 id: Int! 16 username: String! 17 email: String! 18 createdAt: String! 19}
Before this tool, you write graphql api test like this:
1const { GraphQLClient } = require('graphql-request'); 2require('should'); 3 4const host = 'http://localhost:8080/graphql'; 5 6test('signup', async () => { 7 const gql = new GraphQLClient(host); 8 const query = `mutation signup($username: String!, email: String!, password: String!){ 9 signup(username: $username, email: $email, password: $password){ 10 token 11 user { 12 id 13 username 14 email 15 createdAt 16 } 17 } 18 }`; 19 20 const data = await gql.request(query, { 21 username: 'tim', 22 email: 'timqian92@qq.com', 23 password: 'samplepass', 24 }); 25 26 (typeof data.signup.token).should.equal('string'); 27);
As gqlg
generated the queries for you, you don't need to write the query yourself, so your test will becomes:
1const { GraphQLClient } = require('graphql-request'); 2require('should'); 3const mutations = require('./example/output/mutations'); 4 5const host = 'http://localhost:8080/graphql'; 6 7test('signup', async () => { 8 const gql = new GraphQLClient(host); 9 10 const data = await gql.request(mutations.signup, { 11 username: 'tim', 12 email: 'timqian92@qq.com', 13 password: 'samplepass', 14 }); 15 16 (typeof data.signup.token).should.equal('string'); 17);
gqlg
ignores the types which have been added in the parent queries already by default. This can be disabled using the --includeCrossReferences
argument.region(language: $language1)
.No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 10/19 approved changesets -- score normalized to 5
Reason
5 existing vulnerabilities detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More