@ttoss/graphql-api 0.9.10 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -549,6 +549,40 @@ The resolver `connection` has the following arguments based on the [Relay Connec
549
549
  });
550
550
  ```
551
551
 
552
+ #### `ConnectionArgs` type
553
+
554
+ To type a connection resolver in TypeScript, import the generic `ConnectionArgs<TFilter, TSort>` helper. It captures all of the standard pagination arguments (`first`, `after`, `last`, `before`, `limit`, `skip`, `sort`, `filter`) and lets you specify only the connection-specific parts:
555
+
556
+ ```ts
557
+ import {
558
+ type ConnectionArgs,
559
+ type ResolverResolveParams,
560
+ } from '@ttoss/graphql-api';
561
+
562
+ type NotificationFilter = {
563
+ isRead?: boolean | null;
564
+ kind?: string | null;
565
+ };
566
+
567
+ NotificationTC.addResolver({
568
+ name: 'findMany',
569
+ type: [NotificationTC.NonNull],
570
+ resolve: async ({
571
+ args,
572
+ }: ResolverResolveParams<
573
+ unknown,
574
+ ResolverContext,
575
+ ConnectionArgs<NotificationFilter>
576
+ >) => {
577
+ return findManyNotifications({
578
+ first: args.first,
579
+ after: args.after,
580
+ filter: args.filter,
581
+ });
582
+ },
583
+ });
584
+ ```
585
+
552
586
  To configure `composeWithConnection`, you need to provide the following options:
553
587
 
554
588
  #### `findManyResolver`
package/dist/index.d.cts CHANGED
@@ -13,4 +13,35 @@ declare const buildSchema: ({ schemaComposer, middlewares, }: BuildSchemaInput)
13
13
 
14
14
  declare const composeWithRelay: <TContext>(tc: ObjectTypeComposer<any, TContext>) => ObjectTypeComposer<any, TContext>;
15
15
 
16
- export { type BuildSchemaInput, buildSchema, composeWithRelay };
16
+ /**
17
+ * Standard connection arguments used by resolvers created with `composeWithConnection`.
18
+ *
19
+ * @typeParam TFilter - Shape of the connection-specific filter object. Defaults to `unknown`.
20
+ * @typeParam TSort - Shape of the sort value. Defaults to `unknown`.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * import { type ConnectionArgs, type ResolverResolveParams } from '@ttoss/graphql-api';
25
+ *
26
+ * type NotificationFilter = { isRead?: boolean | null };
27
+ *
28
+ * NotificationTC.addResolver({
29
+ * name: 'findMany',
30
+ * resolve: async ({ args }: ResolverResolveParams<unknown, Context, ConnectionArgs<NotificationFilter>>) => {
31
+ * return findMany({ first: args.first, after: args.after, filter: args.filter });
32
+ * },
33
+ * });
34
+ * ```
35
+ */
36
+ type ConnectionArgs<TFilter = unknown, TSort = unknown> = {
37
+ first?: number | null;
38
+ after?: string | null;
39
+ last?: number | null;
40
+ before?: string | null;
41
+ limit?: number | null;
42
+ skip?: number | null;
43
+ sort?: TSort;
44
+ filter?: TFilter | null;
45
+ };
46
+
47
+ export { type BuildSchemaInput, type ConnectionArgs, buildSchema, composeWithRelay };
package/dist/index.d.ts CHANGED
@@ -13,4 +13,35 @@ declare const buildSchema: ({ schemaComposer, middlewares, }: BuildSchemaInput)
13
13
 
14
14
  declare const composeWithRelay: <TContext>(tc: ObjectTypeComposer<any, TContext>) => ObjectTypeComposer<any, TContext>;
15
15
 
16
- export { type BuildSchemaInput, buildSchema, composeWithRelay };
16
+ /**
17
+ * Standard connection arguments used by resolvers created with `composeWithConnection`.
18
+ *
19
+ * @typeParam TFilter - Shape of the connection-specific filter object. Defaults to `unknown`.
20
+ * @typeParam TSort - Shape of the sort value. Defaults to `unknown`.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * import { type ConnectionArgs, type ResolverResolveParams } from '@ttoss/graphql-api';
25
+ *
26
+ * type NotificationFilter = { isRead?: boolean | null };
27
+ *
28
+ * NotificationTC.addResolver({
29
+ * name: 'findMany',
30
+ * resolve: async ({ args }: ResolverResolveParams<unknown, Context, ConnectionArgs<NotificationFilter>>) => {
31
+ * return findMany({ first: args.first, after: args.after, filter: args.filter });
32
+ * },
33
+ * });
34
+ * ```
35
+ */
36
+ type ConnectionArgs<TFilter = unknown, TSort = unknown> = {
37
+ first?: number | null;
38
+ after?: string | null;
39
+ last?: number | null;
40
+ before?: string | null;
41
+ limit?: number | null;
42
+ skip?: number | null;
43
+ sort?: TSort;
44
+ filter?: TFilter | null;
45
+ };
46
+
47
+ export { type BuildSchemaInput, type ConnectionArgs, buildSchema, composeWithRelay };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/graphql-api",
3
- "version": "0.9.10",
3
+ "version": "0.10.0",
4
4
  "description": "A library for building GraphQL APIs using ttoss ecosystem.",
5
5
  "license": "MIT",
6
6
  "author": "ttoss",
@@ -35,7 +35,7 @@
35
35
  "graphql-middleware": "^6.1.35",
36
36
  "graphql-shield": "^7.6.5",
37
37
  "npmlog": "^7.0.1",
38
- "@ttoss/ids": "^0.4.9"
38
+ "@ttoss/ids": "^0.4.10"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "graphql": "^16.6.0"
@@ -44,7 +44,7 @@
44
44
  "graphql": "^16.11.0",
45
45
  "jest": "^30.3.0",
46
46
  "tsup": "^8.5.1",
47
- "@ttoss/config": "^1.37.9"
47
+ "@ttoss/config": "^1.37.10"
48
48
  },
49
49
  "keywords": [
50
50
  "api",