Comparing version 0.0.7 to 0.0.8
const _ = require('lodash') | ||
const generateQuery = require("./generate-example") | ||
const { convertGraphQLType } = require("./type-helpers") | ||
const { digNonNullTypeGraphQL, convertGraphQLType } = require("./type-helpers") | ||
@@ -108,4 +108,4 @@ function getExpandField(expandNotation) { | ||
const gqlField = gqlType.getFields()[name] || {} | ||
// Get its return type so that we can figure out what fields to put in the example | ||
const returnTypeName = _.get(gqlField, 'type.name') | ||
// Get its return type so that we can figure out what fields to put in the example. | ||
const returnTypeName = (digNonNullTypeGraphQL(gqlField.type) || {}).name | ||
// Get the properties for that return type. If the return type is not documented, this will | ||
@@ -176,2 +176,4 @@ // be undefined | ||
// They will presumably have already respected the undocumentedness. | ||
// | ||
// Note to self on the above statement: I think it is already done. | ||
acc.push({ | ||
@@ -202,15 +204,2 @@ field: name, | ||
// if (['currentUser', 'omniSearch', 'organization'].includes(name)) { | ||
// console.log(JSON.stringify({ | ||
// usecases: true, | ||
// expand, | ||
// queryOrMutationName, | ||
// usecase, | ||
// def, | ||
// returnTypeName, | ||
// returnTypeProperties, | ||
// gqlField | ||
// })) | ||
// } | ||
return usecase | ||
@@ -217,0 +206,0 @@ }).sort(sortByProperty('name')) |
@@ -16,2 +16,11 @@ const _ = require('lodash') | ||
function digNonNullTypeGraphQL(graphqlType) { | ||
while (graphqlType instanceof GraphQLNonNull || graphqlType instanceof GraphQLList) { | ||
graphqlType = graphqlType.ofType | ||
} | ||
return graphqlType | ||
} | ||
// Create a JSON Schema and provide metainfo from a GraphQL instance. This is usually | ||
@@ -314,2 +323,3 @@ // from something parsing the Introspection Query results. Like in fetch-schema.js: | ||
module.exports = { | ||
digNonNullTypeGraphQL, | ||
convertGraphQLType, | ||
@@ -316,0 +326,0 @@ convertGraphQLJSONType, |
{ | ||
"name": "spectaql", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "A powerful library for autogenerating static GraphQL API documentation", | ||
@@ -5,0 +5,0 @@ "author": "Anvil Foundry Inc. <hello@useanvil.com>", |
338401
4040