Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected findGqlfieldsOfType(type: ClassType): SortableField[] {
const gqlFields: SortableField[] = []
const resolvers: any[] = []
for (const field of (getMetadataStorage() as any).fields as FieldMetadata[]) {
if (field.target === type) gqlFields.push({
name: field.name,
schemaName: field.schemaName,
type: field.target as any
})
}
for (const resolver of (getMetadataStorage() as any).resolverClasses) {
if (resolver.getObjectType() === type) resolvers.push(resolver.target)
}
for (const fieldResolver of getMetadataStorage().fieldResolvers) {
if (resolvers.includes(fieldResolver.target)) gqlFields.push({
name: fieldResolver.methodName,
schemaName: fieldResolver.schemaName,
type: fieldResolver.target as any
const gqlFields: SortableField[] = []
const resolvers: any[] = []
for (const field of (getMetadataStorage() as any).fields as FieldMetadata[]) {
if (field.target === type) gqlFields.push({
name: field.name,
schemaName: field.schemaName,
type: field.target as any
})
}
for (const resolver of (getMetadataStorage() as any).resolverClasses) {
if (resolver.getObjectType() === type) resolvers.push(resolver.target)
}
for (const fieldResolver of getMetadataStorage().fieldResolvers) {
if (resolvers.includes(fieldResolver.target)) gqlFields.push({
name: fieldResolver.methodName,
schemaName: fieldResolver.schemaName,
type: fieldResolver.target as any
})
}
return gqlFields
}
beforeEach(async () => {
getMetadataStorage().clear()
registerEnumType(OrderingDirection, {
name: "OrderingDirection",
description: "Direction when sorting a column",
});
const schema = createSchema()
EntityA = schema.EntityA
ResolverA = schema.ResolverA
generator = new GQLSortingGenerator()
})