Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@Resolver(() => SortableEntity)
export class SortingResolver {
constructor() {
// Array.of(50).map(() => SortableEntity.insert({}))
}
@Query(() => String)
@Sortable(() => SortableEntity)
public async sortableEntities(
@OrderOptions() order: TypeORMOrdering
) {
return JSON.stringify(order)
}
@RelayedQuery(() => SortableEntity)
public async sortableEntitiesRelayed() {
return SortableEntity.findAndCount({})
}
}
public async beforeSuite(configAutoRelay=true) {
Container.reset();
if(configAutoRelay) {
new AutoRelayConfig(this.config);
}
if(this.runBefore) {
await this.runBefore();
}
}
}
const ThroughEntity = through ? through() as Function : undefined
const throughKey = typeOrmConnection._findPropertyNameBetweenEntityAndThrough(Entity, ThroughEntity)
const findOptions = typeOrmConnection._findOptionsForEntity(field, Entity, self, this, pagination, throughKey, ThroughEntity as Function, options)
const [entities, count] = await getConnection()
.manager
.findAndCount(ThroughEntity || Entity, findOptions as FindManyOptions)
const relayConnection = Relay.connectionFromArraySlice(
entities,
{ after, first, before, last },
{ arrayLength: count, sliceStart: pagination.offset || 0 },
)
if (ThroughEntity) {
return augmentedConnection(relayConnection as Relay.Connection, throughKey)
} else {
return relayConnection as AugmentedConnection
}
}
}