Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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: [],
},
};
static InputObjectTypeDefinition = () =>
generateTypeDefinition({
help: help.input,
type: TypeDefinitionDisplayMap[TypeDefinition.InputObjectTypeDefinition],
dataType: TypeDefinition.InputObjectTypeDefinition,
acceptsInputs: (d, defs, _) =>
Utils.displayAsCategories(
Utils.sortByParentType(Utils.dataForTypes(defs, [TypeDefinition.InputObjectTypeDefinition])),
),
instances: [
{
...InputValueInstance,
acceptsInputs: (d, defs, _) => {
return Utils.dataForTypes(defs, [ValueDefinition.InputValueDefinition]).map(
Utils.nodeDefinitionToAcceptedEditorNodeDefinition,
);
},
instances: [
{
...ArgumentInstance,
static InputObjectTypeDefinition = () =>
generateTypeDefinition({
help: help.input,
type: TypeDefinitionDisplayMap[TypeDefinition.InputObjectTypeDefinition],
dataType: TypeDefinition.InputObjectTypeDefinition,
acceptsInputs: (d, defs, _) =>
Utils.displayAsCategories(
Utils.sortByParentType(Utils.dataForTypes(defs, [TypeDefinition.InputObjectTypeDefinition])),
),
instances: [
{
...InputValueInstance,
acceptsInputs: (d, defs, _) => {
return Utils.dataForTypes(defs, [ValueDefinition.InputValueDefinition]).map(
Utils.nodeDefinitionToAcceptedEditorNodeDefinition,
);
},
instances: [
{
...ArgumentInstance,
acceptsInputs: (d, defs, _) =>
acceptsInputs: (d, defs, _) =>
Utils.displayAsCategories(
Utils.sortByParentType(Utils.dataForTypes(defs, [TypeDefinition.InputObjectTypeDefinition])),
),
instances: [
static resolveTree(tree: ParserTree) {
const { nodes } = tree;
const fakeResolvers = [
TypeDefinition.ObjectTypeDefinition,
TypeDefinition.InterfaceTypeDefinition,
TypeDefinition.InputObjectTypeDefinition
].reduce((a, b) => {
a = {
...a,
...arrayToDict(nodes.filter((n) => n.type.name === b).map(generateFakerResolverType))
};
return a;
}, {});
const fakeEnumResolvers = [TypeDefinition.EnumTypeDefinition].reduce((a, b) => {
a = {
...a,
...arrayToDict(nodes.filter((n) => n.type.name === b).map(generateFakerResolverEnum))
};
return a;
}, {});
Utils.dataForTypes(defs, [Helpers.Implements]).map(Utils.nodeDefinitionToAcceptedEditorNodeDefinition),
help: help.implements,
};
const directivesObject: EditorNodeDefinition = {
node: {
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];
}
}