graphql-compose / graphql-compose-pagination
Showing 2 of 2 files from the diff.

@@ -3,6 +3,9 @@
Loading
3 3
  ObjectTypeComposer,
4 4
  SchemaComposer,
5 5
  InterfaceTypeComposer,
6 +
  UnionTypeComposer,
7 +
  ScalarTypeComposer,
8 +
  EnumTypeComposer,
6 9
} from 'graphql-compose';
7 10
8 11
// PaginationInfo should be global
@@ -41,7 +44,12 @@
Loading
41 44
}
42 45
43 46
export function preparePaginationTC<TSource, TContext>(
44 -
  tc: ObjectTypeComposer<TSource, TContext> | InterfaceTypeComposer<TSource, TContext>,
47 +
  tc:
48 +
    | ObjectTypeComposer<TSource, TContext>
49 +
    | InterfaceTypeComposer<TSource, TContext>
50 +
    | UnionTypeComposer<TSource, TContext>
51 +
    | ScalarTypeComposer<TContext>
52 +
    | EnumTypeComposer<TContext>,
45 53
  resolverName?: string
46 54
): ObjectTypeComposer<TSource, TContext> {
47 55
  const schemaComposer = tc.schemaComposer;

@@ -2,6 +2,9 @@
Loading
2 2
import type {
3 3
  ObjectTypeComposer,
4 4
  InterfaceTypeComposer,
5 +
  UnionTypeComposer,
6 +
  ScalarTypeComposer,
7 +
  EnumTypeComposer,
5 8
  ResolverResolveParams,
6 9
  ObjectTypeComposerArgumentConfigMap,
7 10
} from 'graphql-compose';
@@ -9,6 +12,13 @@
Loading
9 12
10 13
export const DEFAULT_RESOLVER_NAME = 'pagination';
11 14
export const DEFAULT_PER_PAGE = 20;
15 +
const ALLOWED_TYPE_COMPOSERS = [
16 +
  'ObjectTypeComposer',
17 +
  'InterfaceTypeComposer',
18 +
  'UnionTypeComposer',
19 +
  'ScalarTypeComposer',
20 +
  'EnumTypeComposer',
21 +
];
12 22
13 23
export type PaginationResolverOpts = {
14 24
  findManyResolver: Resolver;
@@ -40,12 +50,19 @@
Loading
40 50
}
41 51
42 52
export function preparePaginationResolver<TSource, TContext>(
43 -
  tc: ObjectTypeComposer<TSource, TContext> | InterfaceTypeComposer<TSource, TContext>,
53 +
  tc:
54 +
    | ObjectTypeComposer<TSource, TContext>
55 +
    | InterfaceTypeComposer<TSource, TContext>
56 +
    | UnionTypeComposer<TSource, TContext>
57 +
    | ScalarTypeComposer<TContext>
58 +
    | EnumTypeComposer<TContext>,
44 59
  opts: PaginationResolverOpts
45 60
): Resolver<TSource, TContext, PaginationTArgs> {
46 -
  if (!tc || tc.constructor.name !== 'ObjectTypeComposer') {
61 +
  if (!tc || !ALLOWED_TYPE_COMPOSERS.includes(tc.constructor.name)) {
47 62
    throw new Error(
48 -
      'First arg for prepareConnectionResolver() should be instance of ObjectTypeComposer'
63 +
      `First arg for preparePaginationResolver() should be instance of ${ALLOWED_TYPE_COMPOSERS.join(
64 +
        ' or '
65 +
      )}`
49 66
    );
50 67
  }
51 68
Files Coverage
src 97.80%
Project Totals (3 files) 97.80%
Notifications are pending CI completion. Waiting for GitHub's status webhook to queue notifications. Push notifications now.

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading