@ttoss/graphql-api 0.3.0 → 0.3.3

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
@@ -169,7 +169,7 @@ This package provides a way to add middlewares to your final schema. You can add
169
169
 
170
170
  ```typescript
171
171
  import { buildSchema } from '@ttoss/graphql-api';
172
- import { allow, deny, shield } from 'graphql-shield';
172
+ import { allow, deny, shield } from '@ttoss/graphql-api/shield';
173
173
  import { schemaComposer } from './schemaComposer';
174
174
 
175
175
  const NotAuthorizedError = new Error('Not authorized!');
@@ -201,6 +201,14 @@ const schema = buildSchema({
201
201
  })
202
202
  ```
203
203
 
204
+ #### Shield
205
+
206
+ This package re-exports the all methods from [GraphQL Shield](https://the-guild.dev/graphql/shield).
207
+
208
+ ```typescript
209
+ import { allow, deny, shield } from '@ttoss/graphql-api/shield';
210
+ ```
211
+
204
212
  ## Building Schema
205
213
 
206
214
  As Relay needs an introspection query to work, this package provides a way to build the GraphQL schema by running `ttoss-graphl-api build-schema`.
@@ -0,0 +1,4 @@
1
+ /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
+
3
+ // src/shield.ts
4
+ export * from "graphql-shield";
@@ -0,0 +1,2 @@
1
+ export * from 'graphql-shield';
2
+ export { IMiddleware, IMiddlewareFieldMap, IMiddlewareFunction, IMiddlewareGenerator, IMiddlewareGeneratorConstructor, IMiddlewareTypeMap } from 'graphql-middleware';
package/dist/shield.js ADDED
@@ -0,0 +1,29 @@
1
+ /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
+ "use strict";
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
11
+ get: () => from[key],
12
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
13
+ });
14
+ }
15
+ return to;
16
+ };
17
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: true
20
+ }), mod);
21
+
22
+ // src/shield.ts
23
+ var shield_exports = {};
24
+ module.exports = __toCommonJS(shield_exports);
25
+ __reExport(shield_exports, require("graphql-shield"), module.exports);
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {
28
+ ...require("graphql-shield")
29
+ });
package/package.json CHANGED
@@ -1,11 +1,26 @@
1
1
  {
2
2
  "name": "@ttoss/graphql-api",
3
- "version": "0.3.0",
3
+ "version": "0.3.3",
4
4
  "description": "A library for building GraphQL APIs.",
5
5
  "author": "ttoss",
6
6
  "contributors": [
7
7
  "Pedro Arantes <pedro@arantespp.com> (https://arantespp.com)"
8
8
  ],
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/ttoss/ttoss.git",
12
+ "directory": "packages/graphql-api"
13
+ },
14
+ "exports": {
15
+ ".": {
16
+ "import": "./dist/esm/index.js",
17
+ "require": "./dist/index.js"
18
+ },
19
+ "./shield": {
20
+ "import": "./dist/esm/shield.js",
21
+ "require": "./dist/shield.js"
22
+ }
23
+ },
9
24
  "main": "dist/index.js",
10
25
  "module": "dist/esm/index.js",
11
26
  "bin": {
@@ -21,6 +36,7 @@
21
36
  "graphql-compose": "^9.0.10",
22
37
  "graphql-compose-connection": "^8.2.1",
23
38
  "graphql-middleware": "^6.1.34",
39
+ "graphql-shield": "^7.6.5",
24
40
  "npmlog": "^7.0.1",
25
41
  "ts-node": "^10.9.1",
26
42
  "yargs": "^17.7.2"
@@ -31,17 +47,27 @@
31
47
  "devDependencies": {
32
48
  "@types/yargs": "^17.0.24",
33
49
  "graphql": "^16.6.0",
34
- "graphql-shield": "^7.6.5",
35
50
  "jest": "^29.5.0",
36
51
  "tsup": "^6.7.0",
37
- "@ttoss/config": "^1.30.0"
52
+ "@ttoss/config": "^1.30.3"
38
53
  },
39
54
  "keywords": [
40
55
  "api",
41
56
  "graphql"
42
57
  ],
43
58
  "publishConfig": {
44
- "access": "public"
59
+ "access": "public",
60
+ "provenance": true
61
+ },
62
+ "typesVersions": {
63
+ "*": {
64
+ ".": [
65
+ "./dist/index.d.ts"
66
+ ],
67
+ "shield": [
68
+ "./dist/shield.d.ts"
69
+ ]
70
+ }
45
71
  },
46
72
  "scripts": {
47
73
  "build": "tsup",
@@ -6,6 +6,8 @@ import {
6
6
  } from 'graphql-middleware';
7
7
  import { type SchemaComposer } from 'graphql-compose';
8
8
 
9
+ export type { IMiddleware, IMiddlewareGenerator };
10
+
9
11
  export type BuildSchemaInput<TContext = any> = {
10
12
  schemaComposer: SchemaComposer<TContext>;
11
13
  middlewares?: (IMiddleware | IMiddlewareGenerator<any, TContext, any>)[];
package/src/shield.ts ADDED
@@ -0,0 +1,14 @@
1
+ export * from 'graphql-shield';
2
+ /**
3
+ * Export types from graphql-middleware to avoid "The inferred type of 'x'
4
+ * cannot be named without a reference to '.../graphql-middleware/index.d.ts(1,1)'.
5
+ * This is likely not portable. A type annotation is necessary."
6
+ */
7
+ export type {
8
+ IMiddlewareGenerator,
9
+ IMiddleware,
10
+ IMiddlewareFieldMap,
11
+ IMiddlewareFunction,
12
+ IMiddlewareGeneratorConstructor,
13
+ IMiddlewareTypeMap,
14
+ } from 'graphql-middleware';