graphile-schema 1.10.4 → 1.11.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.
@@ -0,0 +1,27 @@
1
+ import type { TableMeta } from 'graphile-settings';
2
+ import type { BuildSchemaOptions } from './build-schema';
3
+ export type { BuildSchemaOptions as BuildIntrospectionOptions };
4
+ /**
5
+ * Build introspection metadata for all tables visible in the given schemas.
6
+ *
7
+ * Internally calls `buildSchemaSDL()` which triggers the MetaSchemaPlugin
8
+ * gather hook, populating `_cachedTablesMeta` as a side-effect. The cached
9
+ * metadata is then returned as a plain array of `TableMeta` objects.
10
+ *
11
+ * The result includes every table's fields, types, constraints, indexes,
12
+ * relations, inflection names, and query entry-points — the same data
13
+ * exposed by the `_meta` GraphQL query at runtime.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { buildIntrospectionJSON } from 'graphile-schema';
18
+ * import fs from 'fs';
19
+ *
20
+ * const tables = await buildIntrospectionJSON({
21
+ * database: 'my_db',
22
+ * schemas: ['public', 'app_public'],
23
+ * });
24
+ * fs.writeFileSync('introspection.json', JSON.stringify(tables, null, 2));
25
+ * ```
26
+ */
27
+ export declare function buildIntrospectionJSON(opts: BuildSchemaOptions): Promise<TableMeta[]>;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildIntrospectionJSON = buildIntrospectionJSON;
4
+ const graphile_settings_1 = require("graphile-settings");
5
+ const build_schema_1 = require("./build-schema");
6
+ /**
7
+ * Build introspection metadata for all tables visible in the given schemas.
8
+ *
9
+ * Internally calls `buildSchemaSDL()` which triggers the MetaSchemaPlugin
10
+ * gather hook, populating `_cachedTablesMeta` as a side-effect. The cached
11
+ * metadata is then returned as a plain array of `TableMeta` objects.
12
+ *
13
+ * The result includes every table's fields, types, constraints, indexes,
14
+ * relations, inflection names, and query entry-points — the same data
15
+ * exposed by the `_meta` GraphQL query at runtime.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * import { buildIntrospectionJSON } from 'graphile-schema';
20
+ * import fs from 'fs';
21
+ *
22
+ * const tables = await buildIntrospectionJSON({
23
+ * database: 'my_db',
24
+ * schemas: ['public', 'app_public'],
25
+ * });
26
+ * fs.writeFileSync('introspection.json', JSON.stringify(tables, null, 2));
27
+ * ```
28
+ */
29
+ async function buildIntrospectionJSON(opts) {
30
+ await (0, build_schema_1.buildSchemaSDL)(opts);
31
+ return [...graphile_settings_1._cachedTablesMeta];
32
+ }
@@ -0,0 +1,27 @@
1
+ import type { TableMeta } from 'graphile-settings';
2
+ import type { BuildSchemaOptions } from './build-schema';
3
+ export type { BuildSchemaOptions as BuildIntrospectionOptions };
4
+ /**
5
+ * Build introspection metadata for all tables visible in the given schemas.
6
+ *
7
+ * Internally calls `buildSchemaSDL()` which triggers the MetaSchemaPlugin
8
+ * gather hook, populating `_cachedTablesMeta` as a side-effect. The cached
9
+ * metadata is then returned as a plain array of `TableMeta` objects.
10
+ *
11
+ * The result includes every table's fields, types, constraints, indexes,
12
+ * relations, inflection names, and query entry-points — the same data
13
+ * exposed by the `_meta` GraphQL query at runtime.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { buildIntrospectionJSON } from 'graphile-schema';
18
+ * import fs from 'fs';
19
+ *
20
+ * const tables = await buildIntrospectionJSON({
21
+ * database: 'my_db',
22
+ * schemas: ['public', 'app_public'],
23
+ * });
24
+ * fs.writeFileSync('introspection.json', JSON.stringify(tables, null, 2));
25
+ * ```
26
+ */
27
+ export declare function buildIntrospectionJSON(opts: BuildSchemaOptions): Promise<TableMeta[]>;
@@ -0,0 +1,29 @@
1
+ import { _cachedTablesMeta } from 'graphile-settings';
2
+ import { buildSchemaSDL } from './build-schema';
3
+ /**
4
+ * Build introspection metadata for all tables visible in the given schemas.
5
+ *
6
+ * Internally calls `buildSchemaSDL()` which triggers the MetaSchemaPlugin
7
+ * gather hook, populating `_cachedTablesMeta` as a side-effect. The cached
8
+ * metadata is then returned as a plain array of `TableMeta` objects.
9
+ *
10
+ * The result includes every table's fields, types, constraints, indexes,
11
+ * relations, inflection names, and query entry-points — the same data
12
+ * exposed by the `_meta` GraphQL query at runtime.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { buildIntrospectionJSON } from 'graphile-schema';
17
+ * import fs from 'fs';
18
+ *
19
+ * const tables = await buildIntrospectionJSON({
20
+ * database: 'my_db',
21
+ * schemas: ['public', 'app_public'],
22
+ * });
23
+ * fs.writeFileSync('introspection.json', JSON.stringify(tables, null, 2));
24
+ * ```
25
+ */
26
+ export async function buildIntrospectionJSON(opts) {
27
+ await buildSchemaSDL(opts);
28
+ return [..._cachedTablesMeta];
29
+ }
package/esm/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export { buildSchemaSDL } from './build-schema';
2
2
  export type { BuildSchemaOptions } from './build-schema';
3
+ export { buildIntrospectionJSON } from './build-introspection';
3
4
  export { _cachedTablesMeta } from 'graphile-settings';
5
+ export type { TableMeta, FieldMeta, TypeMeta, IndexMeta, ConstraintsMeta, PrimaryKeyConstraintMeta, UniqueConstraintMeta, ForeignKeyConstraintMeta, RelationsMeta, BelongsToRelation, HasRelation, ManyToManyRelation, InflectionMeta, QueryMeta, } from 'graphile-settings';
4
6
  export { fetchEndpointSchemaSDL } from './fetch-endpoint-schema';
5
7
  export type { FetchEndpointSchemaOptions } from './fetch-endpoint-schema';
package/esm/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export { buildSchemaSDL } from './build-schema';
2
+ export { buildIntrospectionJSON } from './build-introspection';
2
3
  export { _cachedTablesMeta } from 'graphile-settings';
3
4
  export { fetchEndpointSchemaSDL } from './fetch-endpoint-schema';
package/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export { buildSchemaSDL } from './build-schema';
2
2
  export type { BuildSchemaOptions } from './build-schema';
3
+ export { buildIntrospectionJSON } from './build-introspection';
3
4
  export { _cachedTablesMeta } from 'graphile-settings';
5
+ export type { TableMeta, FieldMeta, TypeMeta, IndexMeta, ConstraintsMeta, PrimaryKeyConstraintMeta, UniqueConstraintMeta, ForeignKeyConstraintMeta, RelationsMeta, BelongsToRelation, HasRelation, ManyToManyRelation, InflectionMeta, QueryMeta, } from 'graphile-settings';
4
6
  export { fetchEndpointSchemaSDL } from './fetch-endpoint-schema';
5
7
  export type { FetchEndpointSchemaOptions } from './fetch-endpoint-schema';
package/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchEndpointSchemaSDL = exports._cachedTablesMeta = exports.buildSchemaSDL = void 0;
3
+ exports.fetchEndpointSchemaSDL = exports._cachedTablesMeta = exports.buildIntrospectionJSON = exports.buildSchemaSDL = void 0;
4
4
  var build_schema_1 = require("./build-schema");
5
5
  Object.defineProperty(exports, "buildSchemaSDL", { enumerable: true, get: function () { return build_schema_1.buildSchemaSDL; } });
6
+ var build_introspection_1 = require("./build-introspection");
7
+ Object.defineProperty(exports, "buildIntrospectionJSON", { enumerable: true, get: function () { return build_introspection_1.buildIntrospectionJSON; } });
6
8
  var graphile_settings_1 = require("graphile-settings");
7
9
  Object.defineProperty(exports, "_cachedTablesMeta", { enumerable: true, get: function () { return graphile_settings_1._cachedTablesMeta; } });
8
10
  var fetch_endpoint_schema_1 = require("./fetch-endpoint-schema");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphile-schema",
3
- "version": "1.10.4",
3
+ "version": "1.11.0",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "Build GraphQL SDL from PostgreSQL databases using PostGraphile v5",
6
6
  "main": "index.js",
@@ -32,7 +32,7 @@
32
32
  "deepmerge": "^4.3.1",
33
33
  "graphile-build": "5.0.0-rc.6",
34
34
  "graphile-config": "1.0.0-rc.6",
35
- "graphile-settings": "^4.16.2",
35
+ "graphile-settings": "^4.17.0",
36
36
  "graphql": "16.13.0",
37
37
  "pg-cache": "^3.4.1",
38
38
  "pg-env": "^1.8.1"
@@ -50,5 +50,5 @@
50
50
  "introspection",
51
51
  "constructive"
52
52
  ],
53
- "gitHead": "deeabeceebf3300fd6424e157c9d952b0f436f43"
53
+ "gitHead": "1685145fa37391db10d757911b8a6fd00b8c87e7"
54
54
  }