@ttoss/graphql-api 0.4.5 → 0.4.7
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 +11 -3
- package/dist/cli.js +5 -1
- package/dist/esm/cli.js +7 -3
- package/package.json +7 -18
- package/src/cli.ts +7 -5
package/README.md
CHANGED
|
@@ -140,7 +140,7 @@ _We inspired ourselves on [graphql-compose-relay](https://graphql-compose.github
|
|
|
140
140
|
This packages provides the method `composeWithConnection` to create a connection type and queries for a given type, based on [graphql-compose-connection](https://graphql-compose.github.io/docs/plugins/plugin-connection.html) plugin and following the [Relay Connection Specification](https://facebook.github.io/relay/graphql/connections.htm).
|
|
141
141
|
|
|
142
142
|
```typescript
|
|
143
|
-
import { composeWithConnection } from '@ttoss/
|
|
143
|
+
import { composeWithConnection } from '@ttoss/graphql-api';
|
|
144
144
|
|
|
145
145
|
AuthorTC.addResolver({
|
|
146
146
|
name: 'findMany',
|
|
@@ -190,7 +190,7 @@ schemaComposer.Query.addFields({
|
|
|
190
190
|
});
|
|
191
191
|
```
|
|
192
192
|
|
|
193
|
-
When you `composeWithConnection` a type, it will add the resolver `connection` to the type, so you can add to `Query` or any other type:
|
|
193
|
+
When you `composeWithConnection` a type composer, it will add the resolver `connection` to the type composer, so you can add to `Query` or any other type composer. For example:
|
|
194
194
|
|
|
195
195
|
```ts
|
|
196
196
|
schemaComposer.Query.addFields({
|
|
@@ -204,6 +204,8 @@ The resolver `connection` has the following arguments based on the [Relay Connec
|
|
|
204
204
|
- `after`: the cursor to start the query.
|
|
205
205
|
- `last`: the number of nodes to return.
|
|
206
206
|
- `before`: the cursor to start the query.
|
|
207
|
+
- `limit`: the limit of nodes to return. It's the `first` or `last` argument plus one. It's used to know if there are more nodes to return to set `hasNextPage` or `hasPreviousPage` [PageInfo](https://relay.dev/graphql/connections.htm#sec-undefined.PageInfo) fields. For example, if `first` is `10`, `limit` will be `11`. If the resolver returns `11` nodes, the resolver will return `10` but it knows there are more nodes to return, so `hasNextPage` will be `true`.
|
|
208
|
+
- `skip`: it's the `count` minus `last`. It only works on [backward pagination](https://relay.dev/graphql/connections.htm#sec-Backward-pagination-arguments).
|
|
207
209
|
- `sort`: the sort option to use. It's the keys of the `sort` object. In our example, it's `ASC` and `DESC`.
|
|
208
210
|
- `filter`: the filter to use. It'll exist if you add the `filter` to `findManyResolver` for example, the implementation below will add the `filter` argument with the `name` and `book` fields:
|
|
209
211
|
|
|
@@ -249,10 +251,14 @@ The resolver that will be used to find the nodes. It receives the following argu
|
|
|
249
251
|
after?: string;
|
|
250
252
|
last?: number;
|
|
251
253
|
before?: string;
|
|
254
|
+
/**
|
|
255
|
+
* It's the `first` or `last` argument plus one.
|
|
256
|
+
*/
|
|
257
|
+
limit: number;
|
|
252
258
|
/**
|
|
253
259
|
* The `filter` argument, if provided on the query.
|
|
254
260
|
*/
|
|
255
|
-
filter
|
|
261
|
+
filter?: {
|
|
256
262
|
name: string;
|
|
257
263
|
book: string;
|
|
258
264
|
};
|
|
@@ -278,6 +284,8 @@ The resolver that will be used to find the nodes. It receives the following argu
|
|
|
278
284
|
|
|
279
285
|
#### `countResolver`
|
|
280
286
|
|
|
287
|
+
The resolver that will be used to count the nodes.
|
|
288
|
+
|
|
281
289
|
#### `sort`
|
|
282
290
|
|
|
283
291
|
It's an object that defines the sort options. Each key is the sort name and the value is an object with the following properties:
|
package/dist/cli.js
CHANGED
|
@@ -37,7 +37,11 @@ var import_npmlog = __toESM(require("npmlog"));
|
|
|
37
37
|
var import_yargs = __toESM(require("yargs"));
|
|
38
38
|
var logPrefix = "graphql-api";
|
|
39
39
|
(0, import_ts_node.register)({
|
|
40
|
-
transpileOnly: true
|
|
40
|
+
transpileOnly: true,
|
|
41
|
+
compilerOptions: {
|
|
42
|
+
module: "NodeNext",
|
|
43
|
+
moduleResolution: "NodeNext"
|
|
44
|
+
}
|
|
41
45
|
});
|
|
42
46
|
var argv = (0, import_yargs.default)(process.argv.slice(2)).argv;
|
|
43
47
|
(async () => {
|
package/dist/esm/cli.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { __require } from "./chunk-O4CP4YC5.js";
|
|
3
3
|
|
|
4
4
|
// src/cli.ts
|
|
5
|
-
import * as fs from "fs";
|
|
6
|
-
import * as path from "path";
|
|
5
|
+
import * as fs from "node:fs";
|
|
6
|
+
import * as path from "node:path";
|
|
7
7
|
import * as typescriptPlugin from "@graphql-codegen/typescript";
|
|
8
8
|
import { codegen } from "@graphql-codegen/core";
|
|
9
9
|
import { parse } from "graphql";
|
|
@@ -12,7 +12,11 @@ import log from "npmlog";
|
|
|
12
12
|
import yargs from "yargs";
|
|
13
13
|
var logPrefix = "graphql-api";
|
|
14
14
|
register({
|
|
15
|
-
transpileOnly: true
|
|
15
|
+
transpileOnly: true,
|
|
16
|
+
compilerOptions: {
|
|
17
|
+
module: "NodeNext",
|
|
18
|
+
moduleResolution: "NodeNext"
|
|
19
|
+
}
|
|
16
20
|
});
|
|
17
21
|
var argv = yargs(process.argv.slice(2)).argv;
|
|
18
22
|
(async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/graphql-api",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
4
4
|
"description": "A library for building GraphQL APIs using ttoss ecosystem.",
|
|
5
5
|
"author": "ttoss",
|
|
6
6
|
"contributors": [
|
|
@@ -14,15 +14,15 @@
|
|
|
14
14
|
"exports": {
|
|
15
15
|
".": {
|
|
16
16
|
"import": "./dist/esm/index.js",
|
|
17
|
-
"require": "./dist/index.js"
|
|
17
|
+
"require": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts"
|
|
18
19
|
},
|
|
19
20
|
"./shield": {
|
|
20
21
|
"import": "./dist/esm/shield.js",
|
|
21
|
-
"require": "./dist/shield.js"
|
|
22
|
+
"require": "./dist/shield.js",
|
|
23
|
+
"types": "./dist/shield.d.ts"
|
|
22
24
|
}
|
|
23
25
|
},
|
|
24
|
-
"main": "dist/index.js",
|
|
25
|
-
"module": "dist/esm/index.js",
|
|
26
26
|
"bin": {
|
|
27
27
|
"ttoss-graphql-api": "./bin/cli.js"
|
|
28
28
|
},
|
|
@@ -31,7 +31,6 @@
|
|
|
31
31
|
"src"
|
|
32
32
|
],
|
|
33
33
|
"sideEffects": false,
|
|
34
|
-
"typings": "dist/index.d.ts",
|
|
35
34
|
"dependencies": {
|
|
36
35
|
"@graphql-codegen/core": "^4.0.0",
|
|
37
36
|
"@graphql-codegen/typescript": "^4.0.1",
|
|
@@ -40,7 +39,7 @@
|
|
|
40
39
|
"graphql-middleware": "^6.1.35",
|
|
41
40
|
"graphql-shield": "^7.6.5",
|
|
42
41
|
"npmlog": "^7.0.1",
|
|
43
|
-
"ts-node": "^10.9.
|
|
42
|
+
"ts-node": "^10.9.2",
|
|
44
43
|
"yargs": "^17.7.2"
|
|
45
44
|
},
|
|
46
45
|
"peerDependencies": {
|
|
@@ -51,7 +50,7 @@
|
|
|
51
50
|
"graphql": "^16.8.1",
|
|
52
51
|
"jest": "^29.7.0",
|
|
53
52
|
"tsup": "^8.0.1",
|
|
54
|
-
"@ttoss/config": "^1.31.
|
|
53
|
+
"@ttoss/config": "^1.31.4"
|
|
55
54
|
},
|
|
56
55
|
"keywords": [
|
|
57
56
|
"api",
|
|
@@ -61,16 +60,6 @@
|
|
|
61
60
|
"access": "public",
|
|
62
61
|
"provenance": true
|
|
63
62
|
},
|
|
64
|
-
"typesVersions": {
|
|
65
|
-
"*": {
|
|
66
|
-
".": [
|
|
67
|
-
"./dist/index.d.ts"
|
|
68
|
-
],
|
|
69
|
-
"shield": [
|
|
70
|
-
"./dist/shield.d.ts"
|
|
71
|
-
]
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
63
|
"scripts": {
|
|
75
64
|
"build": "tsup",
|
|
76
65
|
"test": "jest"
|
package/src/cli.ts
CHANGED
|
@@ -11,6 +11,10 @@ const logPrefix = 'graphql-api';
|
|
|
11
11
|
|
|
12
12
|
register({
|
|
13
13
|
transpileOnly: true,
|
|
14
|
+
compilerOptions: {
|
|
15
|
+
module: 'NodeNext',
|
|
16
|
+
moduleResolution: 'NodeNext',
|
|
17
|
+
},
|
|
14
18
|
});
|
|
15
19
|
|
|
16
20
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -34,11 +38,9 @@ const argv: any = yargs(process.argv.slice(2)).argv;
|
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
37
|
-
const { schemaComposer } = require(
|
|
38
|
-
process.cwd(),
|
|
39
|
-
|
|
40
|
-
'schemaComposer.ts'
|
|
41
|
-
));
|
|
41
|
+
const { schemaComposer } = require(
|
|
42
|
+
path.resolve(process.cwd(), 'src', 'schemaComposer.ts')
|
|
43
|
+
);
|
|
42
44
|
|
|
43
45
|
const sdl = schemaComposer.toSDL();
|
|
44
46
|
|