Skip to content

Commit

Permalink
Merge pull request #385 from equalogic/renovate/eslint
Browse files Browse the repository at this point in the history
Update eslint
  • Loading branch information
sgarner authored Feb 6, 2022
2 parents 4a6ea24 + c17e0e9 commit 729461d
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 99 deletions.
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class PersonConnection extends createConnectionType(PersonEdge) {}

### Create a Connection Arguments type

Extend a class from `ConnectionArgs` class to have pagination arguments pre-defined for you. You can additionally
Extend a class from `ConnectionArgs` class to have pagination arguments pre-defined for you. You can additionally
define your own arguments for filtering, etc.

```ts
Expand All @@ -51,7 +51,7 @@ export class PersonConnectionArgs extends ConnectionArgs {
/*
* PersonConnectionArgs will inherit `first`, `last`, `before`, `after`, and `page` fields from ConnectionArgs
*/

// Optional: example of a custom argument for filtering
@Field(type => ID, { nullable: true })
public personId?: string;
Expand All @@ -76,20 +76,18 @@ import { OffsetCursorPaginator } from 'nestjs-graphql-connection';
@Resolver()
export class PersonQueryResolver {
@Query(returns => PersonConnection)
public async persons(
@Args() connectionArgs: PersonConnectionArgs,
): Promise<PersonConnection> {
public async persons(@Args() connectionArgs: PersonConnectionArgs): Promise<PersonConnection> {
const { personId } = connectionArgs;

// Example: Count the total number of matching persons (ignoring pagination)
const totalPersons = await countPersons({ where: { personId } });

// Create paginator instance
const paginator = OffsetCursorPaginator.createFromConnectionArgs(connectionArgs, totalPersons);

// Example: Do whatever you need to do to fetch the current page of persons
const persons = await fetchPersons({
where: { personId },
const persons = await fetchPersons({
where: { personId },
take: paginator.take, // how many rows to fetch
skip: paginator.skip, // row offset to fetch from
});
Expand Down
174 changes: 87 additions & 87 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
"@types/graphql-relay": "0.6.0",
"@types/jest": "27.4.0",
"@types/node": "16.11.21",
"@typescript-eslint/eslint-plugin": "5.10.1",
"@typescript-eslint/parser": "5.10.1",
"@typescript-eslint/eslint-plugin": "5.10.2",
"@typescript-eslint/parser": "5.10.2",
"barrelsby": "2.3.2",
"eslint": "8.7.0",
"eslint": "8.8.0",
"eslint-config-prettier": "8.3.0",
"eslint-import-resolver-typescript": "2.5.0",
"eslint-plugin-import": "2.25.4",
Expand Down
2 changes: 1 addition & 1 deletion src/cursor/OffsetCursorPaginator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ConnectionArgsValidationError, CursorValidationError } from '../error';

export type OffsetCursorParameters = {
offset: number;
}
};

export class OffsetCursor extends Cursor<OffsetCursorParameters> {
public static create(encodedString: string): OffsetCursor {
Expand Down

0 comments on commit 729461d

Please sign in to comment.