graphql-to-postman
Advanced tools
Comparing version 0.0.5 to 0.0.6-beta.0
@@ -104,6 +104,9 @@ // Forked from https://github.com/timqian/gql-generator. | ||
* @param {object} gqlSchema | ||
* @param {Number} stack | ||
*/ | ||
function resolveVariableType (type, gqlSchema) { | ||
function resolveVariableType (type, gqlSchema, stack = 0) { | ||
var fieldObj = {}, | ||
stackLimit = 10, | ||
fields; | ||
stack++; | ||
const argType = gqlSchema.getType(getTypeFromTypeObject(type)); | ||
@@ -113,6 +116,11 @@ if (graphql.isInputObjectType(argType)) { | ||
Object.keys(fields).forEach((field) => { | ||
if (type.toString().includes('[') && type.toString().includes(']')) { | ||
fieldObj[field] = [resolveVariableType(fields[field].type, gqlSchema)]; | ||
if (fields[field].type === type) { | ||
fieldObj[field] = '<Same as ' + type + '>'; | ||
} | ||
fieldObj[field] = resolveVariableType(fields[field].type, gqlSchema); | ||
else if (stack <= stackLimit) { | ||
if (type.toString().includes('[') && type.toString().includes(']')) { | ||
fieldObj[field] = [resolveVariableType(fields[field].type, gqlSchema, stack)]; | ||
} | ||
fieldObj[field] = resolveVariableType(fields[field].type, gqlSchema, stack); | ||
} | ||
}); | ||
@@ -119,0 +127,0 @@ return fieldObj; |
@@ -52,2 +52,19 @@ var schemaToQuery = require('./assets/gql-generator').schemaToQuery, | ||
introspectionObject = util.asJson(data); | ||
// introspection query result has the following structure: | ||
// https://graphql.org/learn/introspection/ | ||
// The user can directly provide this | ||
// { | ||
// data: { | ||
// // Or may provide this. | ||
// __schema: { | ||
// } | ||
// } | ||
// } | ||
// Either way, the function `graphql.buildClientSchema` | ||
// only takes in the value of `data` from above. | ||
if (introspectionObject.data) { | ||
introspectionObject = introspectionObject.data; | ||
} | ||
gqlSchemaObj = graphql.buildClientSchema(introspectionObject); | ||
@@ -54,0 +71,0 @@ } |
{ | ||
"name": "graphql-to-postman", | ||
"version": "0.0.5", | ||
"version": "0.0.6-beta.0", | ||
"description": "Generates a Postman Collection from a GraphQL schema.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47800
648