Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
notEditable: true,
name: undefined,
},
type: Helpers.Directives,
data: {
type: Helpers.Directives,
for: [
TypeSystemDefinition.FieldDefinition,
TypeDefinition.ObjectTypeDefinition,
TypeDefinition.EnumTypeDefinition,
TypeDefinition.InputObjectTypeDefinition,
TypeDefinition.InterfaceTypeDefinition,
TypeDefinition.UnionTypeDefinition,
TypeDefinition.ScalarTypeDefinition,
ValueDefinition.EnumValueDefinition,
ValueDefinition.InputValueDefinition,
],
},
acceptsInputs: (d, defs) =>
Utils.dataForTypes(defs, [Helpers.Directives]).map(Utils.nodeDefinitionToAcceptedEditorNodeDefinition),
help: help.directives,
};
return [implementsObject, directivesObject, commentObject];
}
}
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: [],
},
};
const goToInput = (def: EditorNodeDefinition): EditorNodeDefinition => {
if (def.data && def.data.type !== ValueDefinition.InputValueDefinition && def.parent) {
return goToInput(def.parent);
}
return def;
};
const parentInputNode = goToInput(d);
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) =>
defs
.filter((d) => d.data && d.data.type === valueType)
.concat(
Utils.dataForTypes(defs, [ValueDefinition.InputValueDefinition]).filter(
(d) => d.data && d.data.type !== Value.ObjectValue,
),
)
.map(Utils.nodeDefinitionToAcceptedEditorNodeDefinition),
},
acceptsInputs: (d, defs, _) =>
Utils.dataForTypes(defs, [ValueDefinition.InputValueDefinition]).map(
Utils.nodeDefinitionToAcceptedEditorNodeDefinition,
),
},
notEditable: true,
name: undefined,
},
},
],
};
const objectValue: EditorNodeDefinition = {
node: {
...Utils.createOND(Value.ObjectValue, true),
inputs: [],
outputs: [],
},
type: Value.ObjectValue,
data: {
type: Value.ObjectValue,
for: [ValueDefinition.InputValueDefinition],
},
help: help.EnumValue,
acceptsInputs: (d, defs, _, nodes, node) => {
const [createdFromNode] = node!.outputs!;
return Utils.getDefinitionsFromParentInput(createdFromNode.definition, nodes!.concat(stitchNodes)).map(
Utils.nodeDefinitionToAcceptedEditorNodeDefinition,
);
},
instances: undefined,
};
const nullValue: EditorNodeDefinition = {
node: { ...Utils.createOND('null', true), outputs: [], inputs: null },
type: Value.NullValue,
data: {
type: Value.NullValue,
for: [ValueDefinition.InputValueDefinition],