lib/schemaParser.js
function findType (node, typeInfo, nestedCall) {
  typeInfo = typeInfo || { noNull: false, isArray: false, noNullArrayValues: false }
  if (!node) {
    return typeInfo
  }

  // Validate nested call, the parser will check first if the array can be null
  // then it will check if the values inside can be null
  if (!nestedCall && node.kind === 'NonNullType') {
    typeInfo.noNull = true
  }

  // If it is an array, validate if the values inside can be null
  if (nestedCall && typeInfo.isArray && node.kind === 'NonNullType') {
    typeInfo.noNullArrayValues = true
  }

  if (node.kind === 'ListType') {
    typeInfo.isArray = true
  }

  if (node.name) {
    typeInfo.type = node.name.value
  }

  return findType(node.type, typeInfo, true)
}
function findType (node, typeInfo, nestedCall) {
  typeInfo = typeInfo || { noNull: false, isArray: false, noNullArrayValues: false }
  if (!node) {
    return typeInfo
  }

  // Validate nested call, the parser will check first if the array can be null
  // then it will check if the values inside can be null
  if (!nestedCall && node.kind === 'NonNullType') {
    typeInfo.noNull = true
  }

  // If it is an array, validate if the values inside can be null
  if (nestedCall && typeInfo.isArray && node.kind === 'NonNullType') {
    typeInfo.noNullArrayValues = true
  }

  if (node.kind === 'ListType') {
    typeInfo.isArray = true
  }

  if (node.name) {
    typeInfo.type = node.name.value
  }

  return findType(node.type, typeInfo, true)
}
function findType ( node , typeInfo , nestedCall ) { typeInfo = typeInfo || { noNull : false , isArray : false , noNullArrayValues : false } if ( ! node ) { return typeInfo } // Validate nested call, the parser will check first if the array can be null // then it will check if the values inside can be null if ( ! nestedCall && node . kind === 'NonNullType' ) { typeInfo . noNull = true } // If it is an array, validate if the values inside can be null if ( nestedCall && typeInfo . isArray && node . kind === 'NonNullType' ) { typeInfo . noNullArrayValues = true } if ( node . kind === 'ListType' ) { typeInfo . isArray = true } if ( node . name ) { typeInfo . type = node . name . value } return findType ( node . type , typeInfo , true ) }
Find the type of a field on the Schema
@param node - The graph schema
@param typeInfo - The object with the recursive values
@returns {{type: String, noNull: Boolean, isArray: Boolean}}
Find the type of a field on the Schema