Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
}, {});
const fakeScalarResolvers = [TypeDefinition.ScalarTypeDefinition].reduce((a, b) => {
a = {
...a,
...arrayToDict(nodes.filter((n) => n.type.name === b).map(generateFakerResolverScalar))
};
return a;
}, {});
const fakeUnionResolvers = [TypeDefinition.UnionTypeDefinition].reduce((a, b) => {
acceptsInputs: (d, defs) =>
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];
}
}
static generate(stitchNodes: Array>) {
const enumValue: EditorNodeDefinition = {
node: { ...Utils.createOND(), inputs: [], outputs: [] },
type: ValueDefinition.EnumValueDefinition,
data: {
type: ValueDefinition.EnumValueDefinition,
for: [TypeDefinition.EnumTypeDefinition],
},
help: help.EnumValue,
acceptsInputs: (d, defs) =>
Utils.dataForTypes(defs, [ValueDefinition.EnumValueDefinition]).map(
Utils.nodeDefinitionToAcceptedEditorNodeDefinition,
),
instances: [
{
data: {
type: Value.EnumValue,
},
node: {
inputs: null,
outputs: [],
notEditable: true,
name: undefined,
static EnumTypeDefinition = () =>
generateTypeDefinition({
help: help.enum,
type: TypeDefinitionDisplayMap[TypeDefinition.EnumTypeDefinition],
dataType: TypeDefinition.EnumTypeDefinition,
acceptsInputs: (d, defs, _) =>
Utils.dataForTypes(defs, [TypeDefinition.EnumTypeDefinition]).map(
Utils.nodeDefinitionToAcceptedEditorNodeDefinition,
),
instances: [
{
...FieldInstance,
},
{
...InputValueInstance,
help: help.EnumValue,
instances: [
{
...ArgumentInstance,
node: {
notEditable: true,
acceptsInputs: (d, defs, _) =>
Utils.dataForTypes(defs, [TypeDefinition.EnumTypeDefinition]).map(
Utils.nodeDefinitionToAcceptedEditorNodeDefinition,
),
instances: [
static EnumTypeDefinition = () =>
generateTypeDefinition({
help: help.enum,
type: TypeDefinitionDisplayMap[TypeDefinition.EnumTypeDefinition],
dataType: TypeDefinition.EnumTypeDefinition,
acceptsInputs: (d, defs, _) =>
Utils.dataForTypes(defs, [TypeDefinition.EnumTypeDefinition]).map(
Utils.nodeDefinitionToAcceptedEditorNodeDefinition,
),
instances: [
{
...FieldInstance,
},
{
...InputValueInstance,
help: help.EnumValue,
instances: [
{
...ArgumentInstance,
node: {