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:
static UnionTypeDefinition = () =>
generateTypeDefinition({
help: help.union,
type: TypeDefinitionDisplayMap[TypeDefinition.UnionTypeDefinition],
dataType: TypeDefinition.UnionTypeDefinition,
acceptsInputs: (d, defs, _) =>
Utils.dataForTypes(defs, [TypeDefinition.UnionTypeDefinition]).map(
Utils.nodeDefinitionToAcceptedEditorNodeDefinition,
),
instances: [
{
...FieldInstance,
},
],
});
static ObjectTypeDefinition = () =>
acceptsInputs: (d, defs, _) =>
Utils.dataForTypes(defs, [TypeDefinition.UnionTypeDefinition]).map(
Utils.nodeDefinitionToAcceptedEditorNodeDefinition,
),
instances: [
};
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];
}
}
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) => {
a = {
...a,
...arrayToDict(nodes.filter((n) => n.type.name === b).map(generateFakerResolverUnion))
};
return a;
}, {});
const fakeSchema = {
...fakeResolvers,
...fakeEnumResolvers,
...fakeScalarResolvers,
...fakeUnionResolvers
};
return JSON.stringify(fakeSchema, null, 4);
}
}
static UnionTypeDefinition = () =>
generateTypeDefinition({
help: help.union,
type: TypeDefinitionDisplayMap[TypeDefinition.UnionTypeDefinition],
dataType: TypeDefinition.UnionTypeDefinition,
acceptsInputs: (d, defs, _) =>
Utils.dataForTypes(defs, [TypeDefinition.UnionTypeDefinition]).map(
Utils.nodeDefinitionToAcceptedEditorNodeDefinition,
),
instances: [
{
...FieldInstance,
},
],
});
static ObjectTypeDefinition = () =>