@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
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { GraphQLBoolean, GraphQLFloat, GraphQLID, GraphQLInt, GraphQLList, GraphQLString, } from 'graphql';
|
|
2
|
+
import { GraphQLByte, GraphQLDateTime, GraphQLJSON, GraphQLObjectID } from 'graphql-scalars';
|
|
3
|
+
/**
|
|
4
|
+
* Map a Mongoose / BSON path instance type name to a GraphQL output type.
|
|
5
|
+
* Sole document PK (`_id` / asId) uses GraphQL `ID` (federation-friendly).
|
|
6
|
+
* Other ObjectId paths keep graphql-scalars `ObjectID`.
|
|
7
|
+
*/
|
|
8
|
+
export function mapMongoPathToGraphQL(instance, opts) {
|
|
9
|
+
if (opts?.asId) {
|
|
10
|
+
return GraphQLID;
|
|
11
|
+
}
|
|
12
|
+
if (instance === 'ObjectID' || instance === 'ObjectId') {
|
|
13
|
+
return GraphQLObjectID;
|
|
14
|
+
}
|
|
15
|
+
switch (instance) {
|
|
16
|
+
case 'String':
|
|
17
|
+
return GraphQLString;
|
|
18
|
+
case 'Number':
|
|
19
|
+
return GraphQLFloat;
|
|
20
|
+
case 'Decimal128':
|
|
21
|
+
return GraphQLString;
|
|
22
|
+
case 'Boolean':
|
|
23
|
+
return GraphQLBoolean;
|
|
24
|
+
case 'Date':
|
|
25
|
+
return GraphQLDateTime;
|
|
26
|
+
case 'Buffer':
|
|
27
|
+
return GraphQLByte;
|
|
28
|
+
case 'Mixed':
|
|
29
|
+
case 'Array':
|
|
30
|
+
return GraphQLJSON;
|
|
31
|
+
case 'Map':
|
|
32
|
+
return GraphQLJSON;
|
|
33
|
+
case 'Int32':
|
|
34
|
+
return GraphQLInt;
|
|
35
|
+
case 'Double':
|
|
36
|
+
return GraphQLFloat;
|
|
37
|
+
default:
|
|
38
|
+
return GraphQLJSON;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export function mapMongoPathToList(inner) {
|
|
42
|
+
return new GraphQLList(inner);
|
|
43
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@omnigraph/mongo",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"sideEffects": false,
|
|
5
|
+
"peerDependencies": {
|
|
6
|
+
"graphql": "^16.0.0 || ^17.0.0",
|
|
7
|
+
"mongoose": "*"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@graphql-mesh/cross-helpers": "^0.4.18",
|
|
11
|
+
"@graphql-mesh/transport-mongo": "0.1.0",
|
|
12
|
+
"@graphql-mesh/types": "^0.107.3",
|
|
13
|
+
"@graphql-mesh/utils": "^0.107.3",
|
|
14
|
+
"@graphql-tools/utils": "^13.2.2",
|
|
15
|
+
"graphql-compose": "^9.3.0",
|
|
16
|
+
"graphql-scalars": "^2.0.1"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "ardatan/graphql-mesh",
|
|
21
|
+
"directory": "packages/loaders/mongo"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=22.18.0"
|
|
26
|
+
},
|
|
27
|
+
"main": "cjs/index.js",
|
|
28
|
+
"module": "esm/index.js",
|
|
29
|
+
"typings": "typings/index.d.ts",
|
|
30
|
+
"typescript": {
|
|
31
|
+
"definition": "typings/index.d.ts"
|
|
32
|
+
},
|
|
33
|
+
"type": "module",
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"require": {
|
|
37
|
+
"types": "./typings/index.d.cts",
|
|
38
|
+
"default": "./cjs/index.js"
|
|
39
|
+
},
|
|
40
|
+
"import": {
|
|
41
|
+
"types": "./typings/index.d.ts",
|
|
42
|
+
"default": "./esm/index.js"
|
|
43
|
+
},
|
|
44
|
+
"default": {
|
|
45
|
+
"types": "./typings/index.d.ts",
|
|
46
|
+
"default": "./esm/index.js"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"./package.json": "./package.json"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { GraphQLDirective, GraphQLEnumType } from 'graphql';
|
|
2
|
+
/**
|
|
3
|
+
* Single kind enum for `@mongo` (reads, writes, aggregates).
|
|
4
|
+
*/
|
|
5
|
+
export declare const MongoKindEnum: GraphQLEnumType;
|
|
6
|
+
export declare const MongoDirective: GraphQLDirective;
|
|
7
|
+
export { TransportDirective } from '@graphql-mesh/utils';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { GraphQLDirective, GraphQLEnumType } from 'graphql';
|
|
2
|
+
/**
|
|
3
|
+
* Single kind enum for `@mongo` (reads, writes, aggregates).
|
|
4
|
+
*/
|
|
5
|
+
export declare const MongoKindEnum: GraphQLEnumType;
|
|
6
|
+
export declare const MongoDirective: GraphQLDirective;
|
|
7
|
+
export { TransportDirective } from '@graphql-mesh/utils';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { LoadMongoSubgraphOpts } from './schema.cjs';
|
|
2
|
+
export * from './directives.cjs';
|
|
3
|
+
export * from './naming.cjs';
|
|
4
|
+
export * from './schema.cjs';
|
|
5
|
+
export * from './type-map.cjs';
|
|
6
|
+
export declare function loadMongoSubgraph(name: string, opts: LoadMongoSubgraphOpts): () => {
|
|
7
|
+
name: string;
|
|
8
|
+
schema$: Promise<import("graphql").GraphQLSchema>;
|
|
9
|
+
};
|
|
10
|
+
export { getMongoExecutor } from '@graphql-mesh/transport-mongo';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { LoadMongoSubgraphOpts } from './schema.js';
|
|
2
|
+
export * from './directives.js';
|
|
3
|
+
export * from './naming.js';
|
|
4
|
+
export * from './schema.js';
|
|
5
|
+
export * from './type-map.js';
|
|
6
|
+
export declare function loadMongoSubgraph(name: string, opts: LoadMongoSubgraphOpts): () => {
|
|
7
|
+
name: string;
|
|
8
|
+
schema$: Promise<import("graphql").GraphQLSchema>;
|
|
9
|
+
};
|
|
10
|
+
export { getMongoExecutor } from '@graphql-mesh/transport-mongo';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface MongoNaming {
|
|
2
|
+
typeName(modelName: string): string;
|
|
3
|
+
filterInput(typeName: string): string;
|
|
4
|
+
sortInput(typeName: string): string;
|
|
5
|
+
createInput(typeName: string): string;
|
|
6
|
+
updateInput(typeName: string): string;
|
|
7
|
+
payloadType(typeName: string): string;
|
|
8
|
+
connectionType(typeName: string): string;
|
|
9
|
+
edgeType(typeName: string): string;
|
|
10
|
+
paginationType(typeName: string): string;
|
|
11
|
+
findByIdField(typeName: string): string;
|
|
12
|
+
findByIdsField(typeName: string): string;
|
|
13
|
+
findManyField(typeName: string): string;
|
|
14
|
+
findOneField(typeName: string): string;
|
|
15
|
+
countField(typeName: string): string;
|
|
16
|
+
connectionField(typeName: string): string;
|
|
17
|
+
paginationField(typeName: string): string;
|
|
18
|
+
dataLoaderField(typeName: string): string;
|
|
19
|
+
dataLoaderManyField(typeName: string): string;
|
|
20
|
+
createOneField(typeName: string): string;
|
|
21
|
+
createManyField(typeName: string): string;
|
|
22
|
+
updateByIdField(typeName: string): string;
|
|
23
|
+
updateOneField(typeName: string): string;
|
|
24
|
+
updateManyField(typeName: string): string;
|
|
25
|
+
removeByIdField(typeName: string): string;
|
|
26
|
+
removeOneField(typeName: string): string;
|
|
27
|
+
removeManyField(typeName: string): string;
|
|
28
|
+
}
|
|
29
|
+
export declare function createDefaultNaming(): MongoNaming;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface MongoNaming {
|
|
2
|
+
typeName(modelName: string): string;
|
|
3
|
+
filterInput(typeName: string): string;
|
|
4
|
+
sortInput(typeName: string): string;
|
|
5
|
+
createInput(typeName: string): string;
|
|
6
|
+
updateInput(typeName: string): string;
|
|
7
|
+
payloadType(typeName: string): string;
|
|
8
|
+
connectionType(typeName: string): string;
|
|
9
|
+
edgeType(typeName: string): string;
|
|
10
|
+
paginationType(typeName: string): string;
|
|
11
|
+
findByIdField(typeName: string): string;
|
|
12
|
+
findByIdsField(typeName: string): string;
|
|
13
|
+
findManyField(typeName: string): string;
|
|
14
|
+
findOneField(typeName: string): string;
|
|
15
|
+
countField(typeName: string): string;
|
|
16
|
+
connectionField(typeName: string): string;
|
|
17
|
+
paginationField(typeName: string): string;
|
|
18
|
+
dataLoaderField(typeName: string): string;
|
|
19
|
+
dataLoaderManyField(typeName: string): string;
|
|
20
|
+
createOneField(typeName: string): string;
|
|
21
|
+
createManyField(typeName: string): string;
|
|
22
|
+
updateByIdField(typeName: string): string;
|
|
23
|
+
updateOneField(typeName: string): string;
|
|
24
|
+
updateManyField(typeName: string): string;
|
|
25
|
+
removeByIdField(typeName: string): string;
|
|
26
|
+
removeOneField(typeName: string): string;
|
|
27
|
+
removeManyField(typeName: string): string;
|
|
28
|
+
}
|
|
29
|
+
export declare function createDefaultNaming(): MongoNaming;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type GraphQLSchema } from 'graphql';
|
|
2
|
+
import type { Model, Schema as MongooseSchema } from 'mongoose';
|
|
3
|
+
import type { ImportFn } from '@graphql-mesh/types';
|
|
4
|
+
import { type MongoNaming } from './naming.cjs';
|
|
5
|
+
export interface MongoModelConfig {
|
|
6
|
+
name: string;
|
|
7
|
+
path?: string;
|
|
8
|
+
model?: Model<any>;
|
|
9
|
+
schema?: MongooseSchema;
|
|
10
|
+
collection?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface LoadMongoSubgraphOpts {
|
|
13
|
+
endpoint: string;
|
|
14
|
+
models: MongoModelConfig[];
|
|
15
|
+
cwd?: string;
|
|
16
|
+
naming?: Partial<MongoNaming>;
|
|
17
|
+
importFn?: ImportFn;
|
|
18
|
+
}
|
|
19
|
+
export declare function loadGraphQLSchemaFromMongo(subgraphName: string, opts: LoadMongoSubgraphOpts): Promise<GraphQLSchema>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type GraphQLSchema } from 'graphql';
|
|
2
|
+
import type { Model, Schema as MongooseSchema } from 'mongoose';
|
|
3
|
+
import type { ImportFn } from '@graphql-mesh/types';
|
|
4
|
+
import { type MongoNaming } from './naming.js';
|
|
5
|
+
export interface MongoModelConfig {
|
|
6
|
+
name: string;
|
|
7
|
+
path?: string;
|
|
8
|
+
model?: Model<any>;
|
|
9
|
+
schema?: MongooseSchema;
|
|
10
|
+
collection?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface LoadMongoSubgraphOpts {
|
|
13
|
+
endpoint: string;
|
|
14
|
+
models: MongoModelConfig[];
|
|
15
|
+
cwd?: string;
|
|
16
|
+
naming?: Partial<MongoNaming>;
|
|
17
|
+
importFn?: ImportFn;
|
|
18
|
+
}
|
|
19
|
+
export declare function loadGraphQLSchemaFromMongo(subgraphName: string, opts: LoadMongoSubgraphOpts): Promise<GraphQLSchema>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type GraphQLOutputType, type GraphQLScalarType } from 'graphql';
|
|
2
|
+
/**
|
|
3
|
+
* Map a Mongoose / BSON path instance type name to a GraphQL output type.
|
|
4
|
+
* Sole document PK (`_id` / asId) uses GraphQL `ID` (federation-friendly).
|
|
5
|
+
* Other ObjectId paths keep graphql-scalars `ObjectID`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function mapMongoPathToGraphQL(instance: string, opts?: {
|
|
8
|
+
asId?: boolean;
|
|
9
|
+
}): GraphQLOutputType | GraphQLScalarType;
|
|
10
|
+
export declare function mapMongoPathToList(inner: GraphQLOutputType): GraphQLOutputType;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type GraphQLOutputType, type GraphQLScalarType } from 'graphql';
|
|
2
|
+
/**
|
|
3
|
+
* Map a Mongoose / BSON path instance type name to a GraphQL output type.
|
|
4
|
+
* Sole document PK (`_id` / asId) uses GraphQL `ID` (federation-friendly).
|
|
5
|
+
* Other ObjectId paths keep graphql-scalars `ObjectID`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function mapMongoPathToGraphQL(instance: string, opts?: {
|
|
8
|
+
asId?: boolean;
|
|
9
|
+
}): GraphQLOutputType | GraphQLScalarType;
|
|
10
|
+
export declare function mapMongoPathToList(inner: GraphQLOutputType): GraphQLOutputType;
|
package/package.json
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omnigraph/mongo",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "ardatan/graphql-mesh",
|
|
8
|
+
"directory": "packages/loaders/mongo"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=22.18.0"
|
|
13
|
+
},
|
|
14
|
+
"main": "dist/cjs/index.js",
|
|
15
|
+
"module": "dist/esm/index.js",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"require": {
|
|
19
|
+
"types": "./dist/typings/index.d.cts",
|
|
20
|
+
"default": "./dist/cjs/index.js"
|
|
21
|
+
},
|
|
22
|
+
"import": {
|
|
23
|
+
"types": "./dist/typings/index.d.ts",
|
|
24
|
+
"default": "./dist/esm/index.js"
|
|
25
|
+
},
|
|
26
|
+
"default": {
|
|
27
|
+
"types": "./dist/typings/index.d.ts",
|
|
28
|
+
"default": "./dist/esm/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"./package.json": "./package.json"
|
|
32
|
+
},
|
|
33
|
+
"typings": "dist/typings/index.d.ts",
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"graphql": "^16.0.0 || ^17.0.0",
|
|
36
|
+
"mongoose": "*"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@graphql-mesh/cross-helpers": "^0.4.18",
|
|
40
|
+
"@graphql-mesh/transport-mongo": "0.1.0",
|
|
41
|
+
"@graphql-mesh/types": "^0.107.3",
|
|
42
|
+
"@graphql-mesh/utils": "^0.107.3",
|
|
43
|
+
"@graphql-tools/utils": "^13.2.2",
|
|
44
|
+
"graphql-compose": "^9.3.0",
|
|
45
|
+
"graphql-scalars": "^2.0.1"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"graphql": "16.14.0",
|
|
49
|
+
"mongoose": "^9.0.0"
|
|
50
|
+
},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public",
|
|
53
|
+
"directory": "dist"
|
|
54
|
+
},
|
|
55
|
+
"sideEffects": false,
|
|
56
|
+
"typescript": {
|
|
57
|
+
"definition": "dist/typings/index.d.ts"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DirectiveLocation,
|
|
3
|
+
GraphQLDirective,
|
|
4
|
+
GraphQLEnumType,
|
|
5
|
+
GraphQLNonNull,
|
|
6
|
+
GraphQLString,
|
|
7
|
+
} from 'graphql';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Single kind enum for `@mongo` (reads, writes, aggregates).
|
|
11
|
+
*/
|
|
12
|
+
export const MongoKindEnum = new GraphQLEnumType({
|
|
13
|
+
name: 'MongoKind',
|
|
14
|
+
values: {
|
|
15
|
+
FIND_ONE: { value: 'FIND_ONE' },
|
|
16
|
+
FIND_MANY: { value: 'FIND_MANY' },
|
|
17
|
+
COUNT: { value: 'COUNT' },
|
|
18
|
+
CONNECTION: { value: 'CONNECTION' },
|
|
19
|
+
PAGINATION: { value: 'PAGINATION' },
|
|
20
|
+
AGGREGATE: { value: 'AGGREGATE' },
|
|
21
|
+
INSERT_ONE: { value: 'INSERT_ONE' },
|
|
22
|
+
INSERT_MANY: { value: 'INSERT_MANY' },
|
|
23
|
+
UPDATE_ONE: { value: 'UPDATE_ONE' },
|
|
24
|
+
UPDATE_MANY: { value: 'UPDATE_MANY' },
|
|
25
|
+
DELETE_ONE: { value: 'DELETE_ONE' },
|
|
26
|
+
DELETE_MANY: { value: 'DELETE_MANY' },
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export const MongoDirective = new GraphQLDirective({
|
|
31
|
+
name: 'mongo',
|
|
32
|
+
// FIELD: Query/Mutation/nested. OBJECT: type-level entity resolver (`$this` keys).
|
|
33
|
+
locations: [DirectiveLocation.FIELD_DEFINITION, DirectiveLocation.OBJECT],
|
|
34
|
+
args: {
|
|
35
|
+
subgraph: { type: GraphQLString },
|
|
36
|
+
collection: { type: new GraphQLNonNull(GraphQLString) },
|
|
37
|
+
kind: { type: new GraphQLNonNull(MongoKindEnum) },
|
|
38
|
+
/**
|
|
39
|
+
* Equality / join predicates plus Connectors-style spreads
|
|
40
|
+
* (`_id: $this.id`, `...$args.filter`). Mongo-native `filter` naming.
|
|
41
|
+
*/
|
|
42
|
+
filter: { type: GraphQLString },
|
|
43
|
+
/** @deprecated use `filter` */
|
|
44
|
+
where: { type: GraphQLString },
|
|
45
|
+
/** Sort binder (`$args.sort`). */
|
|
46
|
+
sort: { type: GraphQLString },
|
|
47
|
+
/** Limit binder (`$args.limit`). */
|
|
48
|
+
limit: { type: GraphQLString },
|
|
49
|
+
/** Skip binder (`$args.skip`). */
|
|
50
|
+
skip: { type: GraphQLString },
|
|
51
|
+
/** CONNECTION page size (`$args.first`). */
|
|
52
|
+
first: { type: GraphQLString },
|
|
53
|
+
/** CONNECTION cursor (`$args.after`). */
|
|
54
|
+
after: { type: GraphQLString },
|
|
55
|
+
/** PAGINATION page (`$args.page`). */
|
|
56
|
+
page: { type: GraphQLString },
|
|
57
|
+
/** PAGINATION page size (`$args.perPage`). */
|
|
58
|
+
perPage: { type: GraphQLString },
|
|
59
|
+
/** Document values for INSERT / UPDATE. */
|
|
60
|
+
set: { type: GraphQLString },
|
|
61
|
+
selection: { type: GraphQLString },
|
|
62
|
+
/** Aggregate pipeline stages (JSON array string or mapping). */
|
|
63
|
+
pipeline: { type: GraphQLString },
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export { TransportDirective } from '@graphql-mesh/utils';
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { process as meshProcess } from '@graphql-mesh/cross-helpers';
|
|
2
|
+
import type { LoadMongoSubgraphOpts } from './schema.js';
|
|
3
|
+
import { loadGraphQLSchemaFromMongo } from './schema.js';
|
|
4
|
+
|
|
5
|
+
export * from './directives.js';
|
|
6
|
+
export * from './naming.js';
|
|
7
|
+
export * from './schema.js';
|
|
8
|
+
export * from './type-map.js';
|
|
9
|
+
|
|
10
|
+
export function loadMongoSubgraph(name: string, opts: LoadMongoSubgraphOpts) {
|
|
11
|
+
return () => ({
|
|
12
|
+
name,
|
|
13
|
+
schema$: loadGraphQLSchemaFromMongo(name, {
|
|
14
|
+
...opts,
|
|
15
|
+
cwd: opts.cwd || meshProcess.cwd(),
|
|
16
|
+
}),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { getMongoExecutor } from '@graphql-mesh/transport-mongo';
|
package/src/naming.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export interface MongoNaming {
|
|
2
|
+
typeName(modelName: string): string;
|
|
3
|
+
filterInput(typeName: string): string;
|
|
4
|
+
sortInput(typeName: string): string;
|
|
5
|
+
createInput(typeName: string): string;
|
|
6
|
+
updateInput(typeName: string): string;
|
|
7
|
+
payloadType(typeName: string): string;
|
|
8
|
+
connectionType(typeName: string): string;
|
|
9
|
+
edgeType(typeName: string): string;
|
|
10
|
+
paginationType(typeName: string): string;
|
|
11
|
+
findByIdField(typeName: string): string;
|
|
12
|
+
findByIdsField(typeName: string): string;
|
|
13
|
+
findManyField(typeName: string): string;
|
|
14
|
+
findOneField(typeName: string): string;
|
|
15
|
+
countField(typeName: string): string;
|
|
16
|
+
connectionField(typeName: string): string;
|
|
17
|
+
paginationField(typeName: string): string;
|
|
18
|
+
dataLoaderField(typeName: string): string;
|
|
19
|
+
dataLoaderManyField(typeName: string): string;
|
|
20
|
+
createOneField(typeName: string): string;
|
|
21
|
+
createManyField(typeName: string): string;
|
|
22
|
+
updateByIdField(typeName: string): string;
|
|
23
|
+
updateOneField(typeName: string): string;
|
|
24
|
+
updateManyField(typeName: string): string;
|
|
25
|
+
removeByIdField(typeName: string): string;
|
|
26
|
+
removeOneField(typeName: string): string;
|
|
27
|
+
removeManyField(typeName: string): string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function createDefaultNaming(): MongoNaming {
|
|
31
|
+
return {
|
|
32
|
+
typeName: name => name,
|
|
33
|
+
filterInput: typeName => `${typeName}Filter`,
|
|
34
|
+
sortInput: typeName => `${typeName}Sort`,
|
|
35
|
+
createInput: typeName => `CreateOne${typeName}Input`,
|
|
36
|
+
updateInput: typeName => `UpdateById${typeName}Input`,
|
|
37
|
+
payloadType: typeName => `${typeName}Payload`,
|
|
38
|
+
connectionType: typeName => `${typeName}Connection`,
|
|
39
|
+
edgeType: typeName => `${typeName}Edge`,
|
|
40
|
+
paginationType: typeName => `${typeName}Pagination`,
|
|
41
|
+
findByIdField: typeName => `${typeName}_findById`,
|
|
42
|
+
findByIdsField: typeName => `${typeName}_findByIds`,
|
|
43
|
+
findManyField: typeName => `${typeName}_findMany`,
|
|
44
|
+
findOneField: typeName => `${typeName}_findOne`,
|
|
45
|
+
countField: typeName => `${typeName}_count`,
|
|
46
|
+
connectionField: typeName => `${typeName}_connection`,
|
|
47
|
+
paginationField: typeName => `${typeName}_pagination`,
|
|
48
|
+
dataLoaderField: typeName => `${typeName}_dataLoader`,
|
|
49
|
+
dataLoaderManyField: typeName => `${typeName}_dataLoaderMany`,
|
|
50
|
+
createOneField: typeName => `${typeName}_createOne`,
|
|
51
|
+
createManyField: typeName => `${typeName}_createMany`,
|
|
52
|
+
updateByIdField: typeName => `${typeName}_updateById`,
|
|
53
|
+
updateOneField: typeName => `${typeName}_updateOne`,
|
|
54
|
+
updateManyField: typeName => `${typeName}_updateMany`,
|
|
55
|
+
removeByIdField: typeName => `${typeName}_removeById`,
|
|
56
|
+
removeOneField: typeName => `${typeName}_removeOne`,
|
|
57
|
+
removeManyField: typeName => `${typeName}_removeMany`,
|
|
58
|
+
};
|
|
59
|
+
}
|