How to use auto-relay - 3 common examples

To help you get started, we’ve selected a few auto-relay examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wemaintain / auto-relay / tests / suites / _typeorm / sorting.ts View on Github external
@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({})
  }

}
github wemaintain / auto-relay / tests / helpers / auto-relay-runner.ts View on Github external
public async beforeSuite(configAutoRelay=true) {
    Container.reset();
    
    if(configAutoRelay) {
      new AutoRelayConfig(this.config);
    }

    if(this.runBefore) {
      await this.runBefore();
    }
  }
}
github wemaintain / auto-relay / packages / type-orm / src / type-orm-connection.ts View on Github external
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
      }
    }
  }

auto-relay

Relay made simple in code-first GraphQL typescript applications

Apache-2.0
Latest version published 3 years ago

Package Health Score

45 / 100
Full package analysis

Similar packages