@omnigraph/mongo 0.0.0-stage → 0.1.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/CHANGELOG.md +9 -0
- package/dist/cjs/directives.js +62 -0
- package/dist/cjs/index.js +22 -0
- package/dist/cjs/naming.js +33 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/schema.js +762 -0
- package/dist/cjs/type-map.js +47 -0
- package/dist/esm/directives.js +58 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/naming.js +30 -0
- package/dist/esm/schema.js +759 -0
- package/dist/esm/type-map.js +43 -0
- package/dist/package.json +51 -0
- package/dist/typings/directives.d.cts +7 -0
- package/dist/typings/directives.d.ts +7 -0
- package/dist/typings/index.d.cts +10 -0
- package/dist/typings/index.d.ts +10 -0
- package/dist/typings/naming.d.cts +29 -0
- package/dist/typings/naming.d.ts +29 -0
- package/dist/typings/schema.d.cts +19 -0
- package/dist/typings/schema.d.ts +19 -0
- package/dist/typings/type-map.d.cts +10 -0
- package/dist/typings/type-map.d.ts +10 -0
- package/package.json +57 -4
- package/src/directives.ts +67 -0
- package/src/index.ts +20 -0
- package/src/naming.ts +59 -0
- package/src/schema.ts +886 -0
- package/src/type-map.ts +57 -0
- package/test/__snapshots__/mongo-schema.spec.ts.snap +369 -0
- package/test/mongo-schema.spec.ts +58 -0
- package/README.md +0 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# @omnigraph/mongo
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- Initial draft: Mongoose bootstrap emits hand-writable `@mongo` SDL for
|
|
8
|
+
`@graphql-mesh/transport-mongo` (`kind: "mongo"`). First slice covers
|
|
9
|
+
`FIND_ONE` / `FIND_MANY` / `COUNT` with `where` + `selection`.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransportDirective = exports.MongoDirective = exports.MongoKindEnum = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
/**
|
|
6
|
+
* Single kind enum for `@mongo` (reads, writes, aggregates).
|
|
7
|
+
*/
|
|
8
|
+
exports.MongoKindEnum = new graphql_1.GraphQLEnumType({
|
|
9
|
+
name: 'MongoKind',
|
|
10
|
+
values: {
|
|
11
|
+
FIND_ONE: { value: 'FIND_ONE' },
|
|
12
|
+
FIND_MANY: { value: 'FIND_MANY' },
|
|
13
|
+
COUNT: { value: 'COUNT' },
|
|
14
|
+
CONNECTION: { value: 'CONNECTION' },
|
|
15
|
+
PAGINATION: { value: 'PAGINATION' },
|
|
16
|
+
AGGREGATE: { value: 'AGGREGATE' },
|
|
17
|
+
INSERT_ONE: { value: 'INSERT_ONE' },
|
|
18
|
+
INSERT_MANY: { value: 'INSERT_MANY' },
|
|
19
|
+
UPDATE_ONE: { value: 'UPDATE_ONE' },
|
|
20
|
+
UPDATE_MANY: { value: 'UPDATE_MANY' },
|
|
21
|
+
DELETE_ONE: { value: 'DELETE_ONE' },
|
|
22
|
+
DELETE_MANY: { value: 'DELETE_MANY' },
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
exports.MongoDirective = new graphql_1.GraphQLDirective({
|
|
26
|
+
name: 'mongo',
|
|
27
|
+
// FIELD: Query/Mutation/nested. OBJECT: type-level entity resolver (`$this` keys).
|
|
28
|
+
locations: [graphql_1.DirectiveLocation.FIELD_DEFINITION, graphql_1.DirectiveLocation.OBJECT],
|
|
29
|
+
args: {
|
|
30
|
+
subgraph: { type: graphql_1.GraphQLString },
|
|
31
|
+
collection: { type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString) },
|
|
32
|
+
kind: { type: new graphql_1.GraphQLNonNull(exports.MongoKindEnum) },
|
|
33
|
+
/**
|
|
34
|
+
* Equality / join predicates plus Connectors-style spreads
|
|
35
|
+
* (`_id: $this.id`, `...$args.filter`). Mongo-native `filter` naming.
|
|
36
|
+
*/
|
|
37
|
+
filter: { type: graphql_1.GraphQLString },
|
|
38
|
+
/** @deprecated use `filter` */
|
|
39
|
+
where: { type: graphql_1.GraphQLString },
|
|
40
|
+
/** Sort binder (`$args.sort`). */
|
|
41
|
+
sort: { type: graphql_1.GraphQLString },
|
|
42
|
+
/** Limit binder (`$args.limit`). */
|
|
43
|
+
limit: { type: graphql_1.GraphQLString },
|
|
44
|
+
/** Skip binder (`$args.skip`). */
|
|
45
|
+
skip: { type: graphql_1.GraphQLString },
|
|
46
|
+
/** CONNECTION page size (`$args.first`). */
|
|
47
|
+
first: { type: graphql_1.GraphQLString },
|
|
48
|
+
/** CONNECTION cursor (`$args.after`). */
|
|
49
|
+
after: { type: graphql_1.GraphQLString },
|
|
50
|
+
/** PAGINATION page (`$args.page`). */
|
|
51
|
+
page: { type: graphql_1.GraphQLString },
|
|
52
|
+
/** PAGINATION page size (`$args.perPage`). */
|
|
53
|
+
perPage: { type: graphql_1.GraphQLString },
|
|
54
|
+
/** Document values for INSERT / UPDATE. */
|
|
55
|
+
set: { type: graphql_1.GraphQLString },
|
|
56
|
+
selection: { type: graphql_1.GraphQLString },
|
|
57
|
+
/** Aggregate pipeline stages (JSON array string or mapping). */
|
|
58
|
+
pipeline: { type: graphql_1.GraphQLString },
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
var utils_1 = require("@graphql-mesh/utils");
|
|
62
|
+
Object.defineProperty(exports, "TransportDirective", { enumerable: true, get: function () { return utils_1.TransportDirective; } });
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMongoExecutor = void 0;
|
|
4
|
+
exports.loadMongoSubgraph = loadMongoSubgraph;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const cross_helpers_1 = require("@graphql-mesh/cross-helpers");
|
|
7
|
+
const schema_js_1 = require("./schema.js");
|
|
8
|
+
tslib_1.__exportStar(require("./directives.js"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./naming.js"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./schema.js"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./type-map.js"), exports);
|
|
12
|
+
function loadMongoSubgraph(name, opts) {
|
|
13
|
+
return () => ({
|
|
14
|
+
name,
|
|
15
|
+
schema$: (0, schema_js_1.loadGraphQLSchemaFromMongo)(name, {
|
|
16
|
+
...opts,
|
|
17
|
+
cwd: opts.cwd || cross_helpers_1.process.cwd(),
|
|
18
|
+
}),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
var transport_mongo_1 = require("@graphql-mesh/transport-mongo");
|
|
22
|
+
Object.defineProperty(exports, "getMongoExecutor", { enumerable: true, get: function () { return transport_mongo_1.getMongoExecutor; } });
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createDefaultNaming = createDefaultNaming;
|
|
4
|
+
function createDefaultNaming() {
|
|
5
|
+
return {
|
|
6
|
+
typeName: name => name,
|
|
7
|
+
filterInput: typeName => `${typeName}Filter`,
|
|
8
|
+
sortInput: typeName => `${typeName}Sort`,
|
|
9
|
+
createInput: typeName => `CreateOne${typeName}Input`,
|
|
10
|
+
updateInput: typeName => `UpdateById${typeName}Input`,
|
|
11
|
+
payloadType: typeName => `${typeName}Payload`,
|
|
12
|
+
connectionType: typeName => `${typeName}Connection`,
|
|
13
|
+
edgeType: typeName => `${typeName}Edge`,
|
|
14
|
+
paginationType: typeName => `${typeName}Pagination`,
|
|
15
|
+
findByIdField: typeName => `${typeName}_findById`,
|
|
16
|
+
findByIdsField: typeName => `${typeName}_findByIds`,
|
|
17
|
+
findManyField: typeName => `${typeName}_findMany`,
|
|
18
|
+
findOneField: typeName => `${typeName}_findOne`,
|
|
19
|
+
countField: typeName => `${typeName}_count`,
|
|
20
|
+
connectionField: typeName => `${typeName}_connection`,
|
|
21
|
+
paginationField: typeName => `${typeName}_pagination`,
|
|
22
|
+
dataLoaderField: typeName => `${typeName}_dataLoader`,
|
|
23
|
+
dataLoaderManyField: typeName => `${typeName}_dataLoaderMany`,
|
|
24
|
+
createOneField: typeName => `${typeName}_createOne`,
|
|
25
|
+
createManyField: typeName => `${typeName}_createMany`,
|
|
26
|
+
updateByIdField: typeName => `${typeName}_updateById`,
|
|
27
|
+
updateOneField: typeName => `${typeName}_updateOne`,
|
|
28
|
+
updateManyField: typeName => `${typeName}_updateMany`,
|
|
29
|
+
removeByIdField: typeName => `${typeName}_removeById`,
|
|
30
|
+
removeOneField: typeName => `${typeName}_removeOne`,
|
|
31
|
+
removeManyField: typeName => `${typeName}_removeMany`,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|