Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static resolverForConnection = (f: ParserField): string => {
if (f.data) {
const { type = '' } = f.data;
if (type === TypeDefinition.UnionTypeDefinition) {
return TypeDefinitionsTemplates.resolveUnion(f);
}
if (type in Value) {
return ValueTemplate.resolve(f);
}
if (type in TypeDefinition) {
return TypeDefinitionsTemplates.resolve(f);
}
switch (type) {
case TypeSystemDefinition.FieldDefinition:
return FieldTemplate.resolve(f);
case TypeSystemDefinition.DirectiveDefinition:
return TypeDefinitionsTemplates.resolveDirective(f);
case TypeSystemDefinition.UnionMemberDefinition:
return UnionMemberTemplate.resolve(f);
case ValueDefinition.EnumValueDefinition:
return EnumValueDefinitionTemplate.resolve(f);
case ValueDefinition.InputValueDefinition:
return InputValueTemplate.resolve(f);
case Instances.Argument:
return ArgumentTemplate.resolve(f);
case Instances.Directive:
return DirectiveTemplate.resolve(f);
default:
return '';
}
}
return '';
acceptsInputs: (d, defs, _) =>
Utils.displayAsCategories(
Utils.sortByParentType(Utils.dataForTypes(defs, [TypeSystemDefinition.DirectiveDefinition])),
),
instances: [
static resolveObjectNode = (n: Node) => {
const templateField: ParserField = {
name: n.name,
description: n.description,
type: {
name: n.definition.type,
options: n.options && (n.options.filter((o) => o in Options) as Options[]),
operations: n.options && (n.options.filter((o) => o in OperationType) as OperationType[]),
directiveOptions:
n.definition.data!.type! === TypeSystemDefinition.DirectiveDefinition
? (n.options as Directive[])
: undefined,
},
data: n.definition.data,
directives: n.inputs
? n.inputs
.filter((i) => i.definition.type === Helpers.Directives)
.map((i) => i.inputs || [])
.reduce((a, b) => a.concat(b), [])
.map(NodesToTree.resolveFieldNode)
: undefined,
interfaces: n.inputs
? n.inputs
.filter((i) => i.definition.type === Helpers.Implements)
.map((i) => (i.inputs ? i.inputs.map((n) => n.definition.type) : []))
.reduce((a, b) => a.concat(b), [])
static DirectiveDefinition = (stitchNodes: Array>) =>
generateTypeDefinition({
help: help.directive,
type: TypeSystemDefinitionDisplayMap[TypeSystemDefinition.DirectiveDefinition],
dataType: TypeSystemDefinition.DirectiveDefinition,
options: Object.keys(Directive).map((d) => ({ name: d, help: d })),
acceptsInputs: (d, defs, _) =>
Utils.displayAsCategories(
Utils.sortByParentType(Utils.dataForTypes(defs, [TypeSystemDefinition.DirectiveDefinition])),
),
instances: [
{
data: {
type: Instances.Directive,
for: [Helpers.Directives],
},
node: {
notEditable: true,
name: undefined,
},
static DirectiveDefinition = (stitchNodes: Array>) =>
generateTypeDefinition({
help: help.directive,
type: TypeSystemDefinitionDisplayMap[TypeSystemDefinition.DirectiveDefinition],
dataType: TypeSystemDefinition.DirectiveDefinition,
options: Object.keys(Directive).map((d) => ({ name: d, help: d })),
acceptsInputs: (d, defs, _) =>
Utils.displayAsCategories(
Utils.sortByParentType(Utils.dataForTypes(defs, [TypeSystemDefinition.DirectiveDefinition])),
),
instances: [
{
data: {
type: Instances.Directive,
for: [Helpers.Directives],
},
node: {
notEditable: true,
name: undefined,
},
options: undefined,
import { TypeDefinition, TypeSystemDefinition, Value, ValueDefinition } from 'graphql-zeus';
import { EditorNodeDefinition } from '../../Models';
import { Utils } from './Utils';
export const InputValueInstance: Partial & Pick = {
options: Utils.ArrayNonNullOptions,
data: {
type: ValueDefinition.InputValueDefinition,
for: [
TypeDefinition.InputObjectTypeDefinition,
TypeSystemDefinition.FieldDefinition,
TypeSystemDefinition.DirectiveDefinition,
Value.ObjectValue,
],
},
node: {
...Utils.createOND(),
outputs: [],
},
};