@graphql-codegen/typescript-mongodb 2.4.3-alpha-7e47fba48.0 → 2.4.3-alpha-20220805095358-8b7e687d1
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/package.json +5 -5
- package/typings/config.d.cts +86 -0
- package/typings/fields-tree.d.cts +6 -0
- package/typings/index.d.cts +6 -0
- package/typings/visitor.d.cts +30 -0
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/typescript-mongodb",
|
|
3
|
-
"version": "2.4.3-alpha-
|
|
3
|
+
"version": "2.4.3-alpha-20220805095358-8b7e687d1",
|
|
4
4
|
"description": "GraphQL Code Generator plugin for generting a ready-to-use ORM types for MongoDB",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
|
|
7
7
|
"graphql-tag": "^2.0.0"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@graphql-codegen/plugin-helpers": "
|
|
11
|
-
"@graphql-codegen/typescript": "
|
|
12
|
-
"@graphql-codegen/visitor-plugin-common": "2.12.1-alpha-
|
|
10
|
+
"@graphql-codegen/plugin-helpers": "2.6.2-alpha-20220805095358-8b7e687d1",
|
|
11
|
+
"@graphql-codegen/typescript": "2.7.3-alpha-20220805095358-8b7e687d1",
|
|
12
|
+
"@graphql-codegen/visitor-plugin-common": "2.12.1-alpha-20220805095358-8b7e687d1",
|
|
13
13
|
"@graphql-tools/utils": "^8.8.0",
|
|
14
14
|
"auto-bind": "~4.0.0",
|
|
15
15
|
"lodash": "~4.17.0",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"exports": {
|
|
32
32
|
".": {
|
|
33
33
|
"require": {
|
|
34
|
-
"types": "./typings/index.d.
|
|
34
|
+
"types": "./typings/index.d.cts",
|
|
35
35
|
"default": "./cjs/index.js"
|
|
36
36
|
},
|
|
37
37
|
"import": {
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { RawConfig } from '@graphql-codegen/visitor-plugin-common';
|
|
2
|
+
export interface TypeScriptMongoPluginConfig extends RawConfig {
|
|
3
|
+
/**
|
|
4
|
+
* @default DbObject
|
|
5
|
+
* @description Customize the suffix for the generated GraphQL `type`s.
|
|
6
|
+
*
|
|
7
|
+
* @exampleMarkdown
|
|
8
|
+
* ```yaml
|
|
9
|
+
* config:
|
|
10
|
+
* dbTypeSuffix: MyType
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
dbTypeSuffix?: string;
|
|
14
|
+
/**
|
|
15
|
+
* @default DbObject
|
|
16
|
+
* @description Customize the suffix for the generated GraphQL `interface`s.
|
|
17
|
+
*
|
|
18
|
+
* @exampleMarkdown
|
|
19
|
+
* ```yaml
|
|
20
|
+
* config:
|
|
21
|
+
* dbInterfaceSuffix: MyInterface
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
dbInterfaceSuffix?: string;
|
|
25
|
+
/**
|
|
26
|
+
* @default mongodb#ObjectId
|
|
27
|
+
* @description Customize the type of `_id` fields. You can either specify a type name, or specify `module#type`.
|
|
28
|
+
*
|
|
29
|
+
* @exampleMarkdown
|
|
30
|
+
* ```yaml
|
|
31
|
+
* config:
|
|
32
|
+
* objectIdType: ./my-models.ts#MyIdType
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
objectIdType?: string;
|
|
36
|
+
/**
|
|
37
|
+
* @default _id
|
|
38
|
+
* @description Customize the name of the id field generated after using `@id` directive over a GraphQL field.
|
|
39
|
+
*
|
|
40
|
+
* @exampleMarkdown
|
|
41
|
+
* ```yaml
|
|
42
|
+
* config:
|
|
43
|
+
* idFieldName: id
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
idFieldName?: string;
|
|
47
|
+
/**
|
|
48
|
+
* @default true
|
|
49
|
+
* @description Replaces generated `enum` values with `string`.
|
|
50
|
+
*
|
|
51
|
+
* @exampleMarkdown
|
|
52
|
+
* ```yaml
|
|
53
|
+
* config:
|
|
54
|
+
* enumsAsString: false
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
enumsAsString?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* @description This will cause the generator to avoid using TypeScript optionals (`?`),
|
|
60
|
+
* so the following definition: `type A { myField: String }` will output `myField: Maybe<string>`
|
|
61
|
+
* instead of `myField?: Maybe<string>`.
|
|
62
|
+
* @default false
|
|
63
|
+
*
|
|
64
|
+
* @exampleMarkdown
|
|
65
|
+
* ```yaml
|
|
66
|
+
* generates:
|
|
67
|
+
* path/to/file.ts:
|
|
68
|
+
* plugins:
|
|
69
|
+
* - typescript
|
|
70
|
+
* - typescript-mongodb
|
|
71
|
+
* config:
|
|
72
|
+
* avoidOptionals: true
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
avoidOptionals?: boolean;
|
|
76
|
+
}
|
|
77
|
+
export declare enum Directives {
|
|
78
|
+
ID = "id",
|
|
79
|
+
ENTITY = "entity",
|
|
80
|
+
ABSTRACT_ENTITY = "abstractEntity",
|
|
81
|
+
UNION = "union",
|
|
82
|
+
LINK = "link",
|
|
83
|
+
COLUMN = "column",
|
|
84
|
+
EMBEDDED = "embedded",
|
|
85
|
+
MAP = "map"
|
|
86
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PluginFunction, PluginValidateFn } from '@graphql-codegen/plugin-helpers';
|
|
2
|
+
import { TypeScriptMongoPluginConfig } from './config.cjs';
|
|
3
|
+
export declare const plugin: PluginFunction<TypeScriptMongoPluginConfig>;
|
|
4
|
+
export declare const DIRECTIVES: import("graphql").DocumentNode;
|
|
5
|
+
export declare const addToSchema: import("graphql").DocumentNode;
|
|
6
|
+
export declare const validate: PluginValidateFn<any>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ParsedConfig, BaseVisitor } from '@graphql-codegen/visitor-plugin-common';
|
|
2
|
+
import { TypeScriptMongoPluginConfig } from './config.cjs';
|
|
3
|
+
import { GraphQLSchema, ObjectTypeDefinitionNode, InterfaceTypeDefinitionNode, UnionTypeDefinitionNode } from 'graphql';
|
|
4
|
+
export interface TypeScriptMongoPluginParsedConfig extends ParsedConfig {
|
|
5
|
+
dbTypeSuffix: string;
|
|
6
|
+
dbInterfaceSuffix: string;
|
|
7
|
+
objectIdType: string;
|
|
8
|
+
objectIdImport: string;
|
|
9
|
+
idFieldName: string;
|
|
10
|
+
enumsAsString: boolean;
|
|
11
|
+
avoidOptionals: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare class TsMongoVisitor extends BaseVisitor<TypeScriptMongoPluginConfig, TypeScriptMongoPluginParsedConfig> {
|
|
14
|
+
private _schema;
|
|
15
|
+
constructor(_schema: GraphQLSchema, pluginConfig: TypeScriptMongoPluginConfig);
|
|
16
|
+
get objectIdImport(): string;
|
|
17
|
+
private _resolveDirectiveValue;
|
|
18
|
+
private _getDirectiveArgValue;
|
|
19
|
+
private _getDirectiveFromAstNode;
|
|
20
|
+
private _buildInterfaces;
|
|
21
|
+
private _handleIdField;
|
|
22
|
+
private _handleLinkField;
|
|
23
|
+
private _handleColumnField;
|
|
24
|
+
private _handleEmbeddedField;
|
|
25
|
+
private _buildFieldsTree;
|
|
26
|
+
private _addAdditionalFields;
|
|
27
|
+
InterfaceTypeDefinition(node: InterfaceTypeDefinitionNode): string;
|
|
28
|
+
UnionTypeDefinition(node: UnionTypeDefinitionNode): string;
|
|
29
|
+
ObjectTypeDefinition(node: ObjectTypeDefinitionNode): string;
|
|
30
|
+
}
|