@coex/graphql-vercajk
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -8,15 +8,14 @@ import { parse, visit } from "graphql"; | ||
const inputName = node.name.value; | ||
if (!node) | ||
if (!node || !node.fields) | ||
return {}; | ||
if (!node.fields) | ||
return {}; | ||
node.fields.forEach((field, i) => { | ||
node.fields.forEach((field, index) => { | ||
const fieldName = field.name.value; | ||
const isRequired = field.type.kind === "NonNullType"; | ||
const childInputName = getNamedInputType(field); | ||
let children = childInputName ? fieldInfo[childInputName] : null; | ||
const children = childInputName ? fieldInfo[childInputName] : null; | ||
const directive = field.directives?.find(d => d.name.value === config.directiveName); | ||
const constraints = extractDirectiveFields(directive); | ||
if (!fieldInfo[inputName]) | ||
if (!fieldInfo[inputName]) { | ||
fieldInfo[inputName] = {}; | ||
} | ||
fieldInfo[inputName][fieldName] = { | ||
@@ -26,3 +25,3 @@ constraints, | ||
required: isRequired, | ||
order: i, | ||
order: index, | ||
}; | ||
@@ -37,10 +36,10 @@ }); | ||
directive?.arguments?.forEach(arg => { | ||
let val = null; | ||
let value = null; | ||
if (arg.value.kind === 'StringValue' || arg.value.kind === 'BooleanValue' || arg.value.kind === 'EnumValue') { | ||
val = arg.value.value; | ||
value = arg.value.value; | ||
} | ||
if (arg.value.kind === 'FloatValue' || arg.value.kind === 'IntValue') { | ||
val = parseFloat(arg.value.value); | ||
else if (arg.value.kind === 'FloatValue' || arg.value.kind === 'IntValue') { | ||
value = parseFloat(arg.value.value); | ||
} | ||
constraints[arg.name.value] = val; | ||
constraints[arg.name.value] = value; | ||
}); | ||
@@ -47,0 +46,0 @@ return Object.keys(constraints).length !== 0 ? constraints : null; |
{ | ||
"name": "@coex/graphql-vercajk", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Collection of graphql tools", | ||
@@ -5,0 +5,0 @@ "bin": { |
11557
264