@enonic-types/guillotine 0.0.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/Global.Modifying.d.ts +66 -0
- package/README.md +59 -0
- package/Utils.d.ts +23 -0
- package/advanced.ts +157 -0
- package/brand.ts +193 -0
- package/extensions/CreationCallbacks.d.ts +17 -0
- package/extensions/DataFetchingEnvironment.d.ts +15 -0
- package/extensions/Enums.d.ts +9 -0
- package/extensions/Field.d.ts +17 -0
- package/extensions/InputTypes.d.ts +26 -0
- package/extensions/Interfaces.d.ts +13 -0
- package/extensions/Resolver.d.ts +21 -0
- package/extensions/Resolvers.d.ts +16 -0
- package/extensions/TypeResolvers.d.ts +10 -0
- package/extensions/Types.d.ts +15 -0
- package/extensions/Unions.d.ts +12 -0
- package/extensions/index.d.ts +64 -0
- package/graphQL/CreateDataFetcherResult.d.ts +54 -0
- package/graphQL/EnumTypes.d.ts +7 -0
- package/graphQL/InputTypes.d.ts +23 -0
- package/graphQL/InterfaceTypes.d.ts +7 -0
- package/graphQL/LocalContext.d.ts +19 -0
- package/graphQL/ObjectTypes.d.ts +8 -0
- package/graphQL/ReferenceTypes.d.ts +55 -0
- package/graphQL/ScalarTypes.d.ts +35 -0
- package/graphQL/UnionTypes.d.ts +7 -0
- package/graphQL/index.d.ts +172 -0
- package/guillotine/enumTypes.ts +47 -0
- package/guillotine/index.ts +55 -0
- package/guillotine/inputTypes.ts +43 -0
- package/guillotine/objectTypes.ts +340 -0
- package/guillotine/scalarTypes.ts +15 -0
- package/index.ts +157 -0
- package/package.json +50 -0
- package/xp/index.d.ts +22 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// import type {
|
|
2
|
+
// GraphQLBoolean,
|
|
3
|
+
// GraphQLDate,
|
|
4
|
+
// GraphQLDateTime,
|
|
5
|
+
// GraphQLFloat,
|
|
6
|
+
// GraphQLID,
|
|
7
|
+
// GraphQLInt,
|
|
8
|
+
// GraphQLJson,
|
|
9
|
+
// GraphQLLocalDateTime,
|
|
10
|
+
// GraphQLLocalTime,
|
|
11
|
+
// GraphQLString,
|
|
12
|
+
// } from './graphQL/ScalarTypes';
|
|
13
|
+
import {
|
|
14
|
+
ObjectTypeName,
|
|
15
|
+
Content,
|
|
16
|
+
media_Image,
|
|
17
|
+
portal_Site,
|
|
18
|
+
} from './guillotine/objectTypes';
|
|
19
|
+
// import {ScalarTypeName} from './guillotine/ScalarTypes';
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
declare global {
|
|
23
|
+
interface GraphQLEnumTypesMap {
|
|
24
|
+
[enumTypeName: string]: unknown
|
|
25
|
+
}
|
|
26
|
+
interface GraphQLInputTypeFieldsMap {
|
|
27
|
+
[inputTypeName: string]: {
|
|
28
|
+
[inputTypeFieldName: string]: unknown // TODO GraphQLScalars | GraphQLReference<GraphQLInputType>
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
interface GraphQLInputTypesMap {
|
|
32
|
+
[inputTypeName: string]: unknown
|
|
33
|
+
}
|
|
34
|
+
interface GraphQLInterfaceTypesMap {
|
|
35
|
+
[interfaceTypeName: string]: unknown
|
|
36
|
+
}
|
|
37
|
+
interface GraphQLObjectTypeFieldsMap {
|
|
38
|
+
[objectTypeName: string]: {
|
|
39
|
+
[objectTypeFieldName: string]: unknown // TODO GraphQLScalars | GraphQLReference<GraphQLObjectType>
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
interface GraphQLObjectTypesMap {
|
|
43
|
+
[ObjectTypeName.Content]: Content
|
|
44
|
+
[ObjectTypeName.media_Image]: media_Image
|
|
45
|
+
[ObjectTypeName.portal_Site]: portal_Site
|
|
46
|
+
[typeName: string]: unknown
|
|
47
|
+
}
|
|
48
|
+
// interface GraphQLScalarTypesMap {
|
|
49
|
+
// [ScalarTypeName.Boolean]: GraphQLBoolean
|
|
50
|
+
// [ScalarTypeName.Date]: GraphQLDate
|
|
51
|
+
// [ScalarTypeName.DateTime]: GraphQLDateTime
|
|
52
|
+
// [ScalarTypeName.Float]: GraphQLFloat
|
|
53
|
+
// [ScalarTypeName.ID]: GraphQLID
|
|
54
|
+
// [ScalarTypeName.Json]: GraphQLJson
|
|
55
|
+
// [ScalarTypeName.Int]: GraphQLInt
|
|
56
|
+
// [ScalarTypeName.LocalDateTime]: GraphQLLocalDateTime
|
|
57
|
+
// [ScalarTypeName.LocalTime]: GraphQLLocalTime
|
|
58
|
+
// [ScalarTypeName.String]: GraphQLString
|
|
59
|
+
// }
|
|
60
|
+
interface GraphQLUnionTypesMap {
|
|
61
|
+
[unionTypeName: string]: unknown
|
|
62
|
+
}
|
|
63
|
+
} // global
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
export {}
|
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Guillotine types
|
|
2
|
+
|
|
3
|
+
Type definitions for [Guillotine](https://market.enonic.com/vendors/enonic/guillotine) - augmentable GraphQL Content API for Enonic XP.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import type {GraphQL, Extensions} from '@enonic-types/guillotine';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
import {ObjectTypeName} from '@enonic-types/guillotine';
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
const MY_OBJECT_TYPE_NAME = 'MyObjectType';
|
|
15
|
+
const MY_FIELD_NAME = 'myField';
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
export const extensions = (graphQL: GraphQL): Extensions => {
|
|
19
|
+
return {
|
|
20
|
+
types: {
|
|
21
|
+
[MY_OBJECT_TYPE_NAME]: {
|
|
22
|
+
description: 'Description for my object type',
|
|
23
|
+
fields: {
|
|
24
|
+
myString: {
|
|
25
|
+
type: graphQL.nonNull(graphQL.GraphQLString),
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
creationCallbacks: {
|
|
31
|
+
[ObjectTypeName.Content]: (params) => {
|
|
32
|
+
params.addFields({
|
|
33
|
+
[MY_FIELD_NAME]: {
|
|
34
|
+
type: graphQL.reference(MY_OBJECT_TYPE_NAME)
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
resolvers: {
|
|
40
|
+
[ObjectTypeName.Content]: {
|
|
41
|
+
[MY_FIELD_NAME]: () => {
|
|
42
|
+
const {
|
|
43
|
+
// args,
|
|
44
|
+
// localContext,
|
|
45
|
+
source: content
|
|
46
|
+
} = env;
|
|
47
|
+
if (content.type === 'portal:fragment') {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
myString: 'Hello, World!'
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
```
|
package/Utils.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare type ArrayElement<ArrayType extends readonly unknown[]> =
|
|
2
|
+
ArrayType extends readonly (infer ElementType)[] ? ElementType : never
|
|
3
|
+
|
|
4
|
+
export declare type ParsedJSON =
|
|
5
|
+
| string // double-quoted inside the JSON string, but normal string after parsing
|
|
6
|
+
| number
|
|
7
|
+
| boolean
|
|
8
|
+
| null
|
|
9
|
+
// | { [key: string]: any } // This works both for types and interfaces :)
|
|
10
|
+
| Record<string, any> // This works both for types and interfaces :)
|
|
11
|
+
// | { [key: string]: unknown } // This works for types, but NOT interfaces :(
|
|
12
|
+
// | Record<string, unknown> // This works for types, but NOT interfaces :(
|
|
13
|
+
// | { [key: string]: ParsedJSON } // This works for types, but NOT interfaces :(
|
|
14
|
+
// | Record<string, ParsedJSON> // Causes: Type alias ParsedJSON circularly references itself. :(
|
|
15
|
+
| ParsedJSON[]
|
|
16
|
+
|
|
17
|
+
export declare type PartialRecord<K extends keyof any, T> = {
|
|
18
|
+
[P in K]?: T
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type RecordValueType<T> = T extends Record<string, infer U> ? U : never;
|
|
22
|
+
|
|
23
|
+
export declare type ValueOf<T> = T[keyof T]
|
package/advanced.ts
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
There are several "sets" of types when working with Guillotine Extensions:
|
|
4
|
+
|
|
5
|
+
1. The types that are used in the GraphQL schema definition.
|
|
6
|
+
2. The types that are passed into resolvers via the source parameter.
|
|
7
|
+
3. The types that are returned from resolvers.
|
|
8
|
+
|
|
9
|
+
All these types are related, but they are not the same, and conversion between is sketchy.
|
|
10
|
+
Especically when the GraphQL schema just uses JSON, but returns a complex object.
|
|
11
|
+
|
|
12
|
+
A resolver can return:
|
|
13
|
+
|
|
14
|
+
1. a nested data set
|
|
15
|
+
2. a flat data set, and let other resolvers handle the nested data
|
|
16
|
+
3. a combination of both
|
|
17
|
+
|
|
18
|
+
In resolvers the type of source does NOT match the GraphQLSchema.
|
|
19
|
+
It seems to match Enonic "Core" types with some extensions.
|
|
20
|
+
For example "attachments" currently have a "__contentId" field that will be removed in Guillotine 8.
|
|
21
|
+
|
|
22
|
+
In "nested" resolvers the type of source depends on what the parent resolver returns.
|
|
23
|
+
|
|
24
|
+
In resolvers the type of localContext depends on a combination of all ancestor resolvers.
|
|
25
|
+
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/// <reference path="./Global.Modifying.d.ts"/>
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
export type {
|
|
32
|
+
Brand,
|
|
33
|
+
BrandGraphQLObjectType,
|
|
34
|
+
BrandGraphQLScalarType,
|
|
35
|
+
GetParsedJson,
|
|
36
|
+
GetNonNull,
|
|
37
|
+
GetReturnType,
|
|
38
|
+
GetSuperType,
|
|
39
|
+
GetTypeName,
|
|
40
|
+
GetReference,
|
|
41
|
+
NonNull,
|
|
42
|
+
Reference,
|
|
43
|
+
} from './brand'
|
|
44
|
+
|
|
45
|
+
export type {
|
|
46
|
+
// AnyResolver, // Not certain this should be exported
|
|
47
|
+
CreationCallback,
|
|
48
|
+
CreationCallbacks,
|
|
49
|
+
DataFetchingEnvironment,
|
|
50
|
+
Enum,
|
|
51
|
+
Enums,
|
|
52
|
+
Extensions,
|
|
53
|
+
Field,
|
|
54
|
+
Fields,
|
|
55
|
+
InputType,
|
|
56
|
+
InputTypeField,
|
|
57
|
+
InputTypeFields,
|
|
58
|
+
InputTypes,
|
|
59
|
+
Resolver,
|
|
60
|
+
Resolvers,
|
|
61
|
+
Type,
|
|
62
|
+
TypeResolver,
|
|
63
|
+
TypeResolvers,
|
|
64
|
+
Types,
|
|
65
|
+
Union,
|
|
66
|
+
Unions
|
|
67
|
+
} from './extensions'
|
|
68
|
+
|
|
69
|
+
export type {
|
|
70
|
+
CreateDataFetcherResult,
|
|
71
|
+
CreateDataFetcherResultParams,
|
|
72
|
+
GraphQL,
|
|
73
|
+
GraphQLArgs,
|
|
74
|
+
GraphQLBaseScalars,
|
|
75
|
+
GraphQLBoolean,
|
|
76
|
+
GraphQLCustomScalars,
|
|
77
|
+
GraphQLEnumTypeReference,
|
|
78
|
+
GraphQLDate,
|
|
79
|
+
GraphQLDateTime,
|
|
80
|
+
GraphQLExtendedScalars,
|
|
81
|
+
GraphQLFloat,
|
|
82
|
+
GraphQLID,
|
|
83
|
+
GraphQLInputType,
|
|
84
|
+
GraphQLInputTypeReference,
|
|
85
|
+
GraphQLInputTypeName,
|
|
86
|
+
GraphQLInt,
|
|
87
|
+
GraphQLInterfaceTypeReference,
|
|
88
|
+
GraphQLJson,
|
|
89
|
+
GraphQLLocalDateTime,
|
|
90
|
+
GraphQLLocalTime,
|
|
91
|
+
GraphQLNonNull,
|
|
92
|
+
GraphQLObjectType,
|
|
93
|
+
GraphQLObjectTypeName,
|
|
94
|
+
GraphQLObjectTypeReference,
|
|
95
|
+
GraphQLScalars,
|
|
96
|
+
GraphQLString,
|
|
97
|
+
GraphQLTypeToGuillotineFields,
|
|
98
|
+
GraphQLTypeToResolverResult,
|
|
99
|
+
GraphQLUnionTypeReference,
|
|
100
|
+
LocalContext,
|
|
101
|
+
LocalContextRecord,
|
|
102
|
+
} from './graphQL'
|
|
103
|
+
|
|
104
|
+
export type {
|
|
105
|
+
AccessControlEntry,
|
|
106
|
+
Attachment,
|
|
107
|
+
EnumTypeNames,
|
|
108
|
+
InputTypeNames,
|
|
109
|
+
ObjectTypeNames,
|
|
110
|
+
ScalarTypeNames,
|
|
111
|
+
Content,
|
|
112
|
+
ContentConnection,
|
|
113
|
+
ContentEdge,
|
|
114
|
+
ContentType,
|
|
115
|
+
ExtraData,
|
|
116
|
+
FormItem,
|
|
117
|
+
GeoPoint,
|
|
118
|
+
Icon,
|
|
119
|
+
media_Image,
|
|
120
|
+
media_Image_Data,
|
|
121
|
+
MediaFocalPoint,
|
|
122
|
+
MediaUploader,
|
|
123
|
+
PageInfo,
|
|
124
|
+
Permissions,
|
|
125
|
+
portal_Site,
|
|
126
|
+
portal_Site_Data,
|
|
127
|
+
PrincipalKey,
|
|
128
|
+
PublishInfo,
|
|
129
|
+
XData_base_ApplicationConfig,
|
|
130
|
+
XData_base_gpsInfo_DataConfig,
|
|
131
|
+
XData_media_ApplicationConfig,
|
|
132
|
+
XData_media_cameraInfo_DataConfig,
|
|
133
|
+
XData_media_imageInfo_DataConfig,
|
|
134
|
+
} from './guillotine'
|
|
135
|
+
|
|
136
|
+
export type {
|
|
137
|
+
BaseFolderContent,
|
|
138
|
+
MediaImageContent,
|
|
139
|
+
PortalSiteContent,
|
|
140
|
+
} from './xp'
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
export {
|
|
144
|
+
EnumTypeName,
|
|
145
|
+
InputTypeName,
|
|
146
|
+
ObjectTypeName,
|
|
147
|
+
ScalarTypeName,
|
|
148
|
+
FormItemType,
|
|
149
|
+
Permission,
|
|
150
|
+
PrincipalType,
|
|
151
|
+
} from './guillotine'
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
export {
|
|
155
|
+
jsonParse,
|
|
156
|
+
jsonStringify,
|
|
157
|
+
} from './brand'
|
package/brand.ts
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import type {ParsedJSON} from './Utils'
|
|
2
|
+
|
|
3
|
+
//──────────────────────────────────────────────────────────────────────────────
|
|
4
|
+
// Unique symbols (only available in this file)
|
|
5
|
+
//──────────────────────────────────────────────────────────────────────────────
|
|
6
|
+
declare const __superType: unique symbol
|
|
7
|
+
declare const __name: unique symbol
|
|
8
|
+
declare const __parsedJsonType: unique symbol
|
|
9
|
+
|
|
10
|
+
// GraphQL related
|
|
11
|
+
declare const __nonNull: unique symbol
|
|
12
|
+
declare const __reference: unique symbol
|
|
13
|
+
declare const __returnType: unique symbol
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
//──────────────────────────────────────────────────────────────────────────────
|
|
17
|
+
// Non-exported types
|
|
18
|
+
//──────────────────────────────────────────────────────────────────────────────
|
|
19
|
+
|
|
20
|
+
// WARNING: Do NOT export this type, it uses symbols only available in this file.
|
|
21
|
+
declare interface MetaObject<
|
|
22
|
+
TYPE_NAME extends string, // All branded types need a unique name to be distinguisable in discriminated unions.
|
|
23
|
+
SUPER_TYPE extends any,
|
|
24
|
+
PARSED_JSON_TYPE extends ParsedJSON|undefined = undefined
|
|
25
|
+
> {
|
|
26
|
+
[__name]: TYPE_NAME
|
|
27
|
+
[__parsedJsonType]: PARSED_JSON_TYPE
|
|
28
|
+
[__superType]: SUPER_TYPE
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// WARNING: Do NOT export this type, it uses symbols only available in this file.
|
|
32
|
+
declare interface GraphQLMetaObject<
|
|
33
|
+
TYPE_NAME extends string,
|
|
34
|
+
SUPER_TYPE extends any,
|
|
35
|
+
PARSED_JSON_TYPE extends ParsedJSON|undefined = undefined,
|
|
36
|
+
NON_NULL extends boolean = false, // Both Objects and Scalars can be non-null
|
|
37
|
+
RETURN_TYPE extends any = undefined, // Only Objects have a return type
|
|
38
|
+
REFERENCE extends boolean = false, // Only Objects can be referenced to
|
|
39
|
+
> extends MetaObject<TYPE_NAME, SUPER_TYPE, PARSED_JSON_TYPE> {
|
|
40
|
+
[__nonNull]: NON_NULL
|
|
41
|
+
[__reference]: REFERENCE
|
|
42
|
+
[__returnType]: RETURN_TYPE
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// WARNING: Do NOT export this type, BrandGraphQLObjectType and BrandGraphQLScalarType should be used instead.
|
|
46
|
+
declare type BrandGraphQL<
|
|
47
|
+
TYPE_NAME extends string,
|
|
48
|
+
SUPER_TYPE extends any,
|
|
49
|
+
PARSED_JSON_TYPE extends ParsedJSON|undefined = undefined,
|
|
50
|
+
NON_NULL extends boolean = false,
|
|
51
|
+
RETURN_TYPE extends any = undefined,
|
|
52
|
+
REFERENCE extends boolean = false
|
|
53
|
+
> = SUPER_TYPE & GraphQLMetaObject<
|
|
54
|
+
TYPE_NAME, // 1. Type name
|
|
55
|
+
SUPER_TYPE, // 2. Super type
|
|
56
|
+
PARSED_JSON_TYPE, // 3. Parsed JSON type
|
|
57
|
+
NON_NULL, // 4. Non-null
|
|
58
|
+
RETURN_TYPE, // 5. Return type
|
|
59
|
+
REFERENCE // 6. Reference
|
|
60
|
+
>
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
//──────────────────────────────────────────────────────────────────────────────
|
|
64
|
+
// Exported types
|
|
65
|
+
//──────────────────────────────────────────────────────────────────────────────
|
|
66
|
+
export type AnyBrand = MetaObject<
|
|
67
|
+
string, // 1. Type name
|
|
68
|
+
any, // 2. Super type
|
|
69
|
+
any // 3. Parsed JSON type
|
|
70
|
+
>
|
|
71
|
+
|
|
72
|
+
// export type AnyJson = MetaObject<any, string, ParsedJSON>
|
|
73
|
+
|
|
74
|
+
export type AnyGraphQLBrand = GraphQLMetaObject<
|
|
75
|
+
string, // 1. Type name
|
|
76
|
+
any, // 2. Super type
|
|
77
|
+
any, // 3. Parsed JSON type
|
|
78
|
+
boolean, // 4. Non-null
|
|
79
|
+
any, // 5. Return type
|
|
80
|
+
boolean // 6. Reference
|
|
81
|
+
>
|
|
82
|
+
|
|
83
|
+
export declare type Brand<
|
|
84
|
+
TYPE_NAME extends string,
|
|
85
|
+
SUPER_TYPE,
|
|
86
|
+
PARSED_JSON_TYPE extends ParsedJSON|undefined = undefined
|
|
87
|
+
> = SUPER_TYPE & MetaObject<
|
|
88
|
+
TYPE_NAME, // 1. Type name
|
|
89
|
+
SUPER_TYPE, // 2. Super type
|
|
90
|
+
PARSED_JSON_TYPE // 3. Parsed JSON type
|
|
91
|
+
>
|
|
92
|
+
|
|
93
|
+
export declare type GetTypeName<T> = T extends MetaObject<
|
|
94
|
+
infer TYPE_NAME, // 1. Type name
|
|
95
|
+
any, // 2. Super type
|
|
96
|
+
any // 3. Parsed JSON type
|
|
97
|
+
> ? TYPE_NAME : never
|
|
98
|
+
|
|
99
|
+
export declare type GetSuperType<T> = T extends MetaObject<
|
|
100
|
+
any, // 1. Type name
|
|
101
|
+
infer SUPER_TYPE, // 2. Super type
|
|
102
|
+
any // 3. Parsed JSON type
|
|
103
|
+
> ? SUPER_TYPE : never
|
|
104
|
+
|
|
105
|
+
export declare type GetParsedJson<T> = T extends MetaObject<
|
|
106
|
+
any, // 1. Type name
|
|
107
|
+
any, // 2. Super type
|
|
108
|
+
infer PARSED_JSON_TYPE // 3. Parsed JSON type
|
|
109
|
+
> ? PARSED_JSON_TYPE : never
|
|
110
|
+
|
|
111
|
+
export declare type GetNonNull<T> = T extends GraphQLMetaObject<
|
|
112
|
+
string, // 1. Type name
|
|
113
|
+
any, // 2. Super type
|
|
114
|
+
any, // 3. Parsed JSON type
|
|
115
|
+
infer NON_NULL, // 4. Non-null
|
|
116
|
+
any, // 5. Return type
|
|
117
|
+
any // 6. Reference
|
|
118
|
+
> ? NON_NULL : never
|
|
119
|
+
|
|
120
|
+
export declare type GetReturnType<T> = T extends GraphQLMetaObject<
|
|
121
|
+
string, // 1. Type name
|
|
122
|
+
any, // 2. Super type
|
|
123
|
+
any, // 3. Parsed JSON type
|
|
124
|
+
any, // 4. Non-null
|
|
125
|
+
infer RETURN_TYPE, // 5. Return type
|
|
126
|
+
any // 6. Reference
|
|
127
|
+
> ? RETURN_TYPE : never
|
|
128
|
+
|
|
129
|
+
export declare type GetReference<T> = T extends GraphQLMetaObject<
|
|
130
|
+
string, // 1. Type name
|
|
131
|
+
any, // 2. Super type
|
|
132
|
+
any, // 3. Parsed JSON type
|
|
133
|
+
any, // 4. Non-null
|
|
134
|
+
any, // 5. Return type
|
|
135
|
+
infer REFERENCE // 6. Reference
|
|
136
|
+
> ? REFERENCE : never
|
|
137
|
+
|
|
138
|
+
export declare type NonNull<T> = BrandGraphQL<
|
|
139
|
+
GetTypeName<T>, // 1. Type name
|
|
140
|
+
GetSuperType<T>, // 2. Super type
|
|
141
|
+
GetParsedJson<T>, // 3. Parsed JSON type
|
|
142
|
+
true, // 4. Non-null
|
|
143
|
+
GetReturnType<T>, // 5. Return type
|
|
144
|
+
GetReference<T> // 6. Reference
|
|
145
|
+
>
|
|
146
|
+
|
|
147
|
+
export declare type Reference<T> = BrandGraphQL<
|
|
148
|
+
GetTypeName<T>, // 1. Type name
|
|
149
|
+
GetSuperType<T>, // 2. Super type
|
|
150
|
+
GetParsedJson<T>, // 3. Parsed JSON type
|
|
151
|
+
GetNonNull<T>, // 4. Non-null
|
|
152
|
+
GetReturnType<T>, // 5. Return type
|
|
153
|
+
true // 6. Reference
|
|
154
|
+
>
|
|
155
|
+
|
|
156
|
+
// NonNull and Reference can be applied via wrapping.
|
|
157
|
+
export declare type BrandGraphQLObjectType<
|
|
158
|
+
GQL_OBJECT_TYPE_NAME extends string,
|
|
159
|
+
GQL_OBJECT_TYPE extends Record<string, any>,
|
|
160
|
+
RETURN_TYPE extends any = undefined,
|
|
161
|
+
> = BrandGraphQL<
|
|
162
|
+
GQL_OBJECT_TYPE_NAME, // 1. Type name
|
|
163
|
+
GQL_OBJECT_TYPE, // 2. Super type
|
|
164
|
+
undefined, // 3. Parsed JSON type
|
|
165
|
+
false, // 4. Non-null
|
|
166
|
+
RETURN_TYPE, // 5. Return type
|
|
167
|
+
false // 6. Reference
|
|
168
|
+
>
|
|
169
|
+
|
|
170
|
+
// NonNull can be applied via wrapping.
|
|
171
|
+
export declare type BrandGraphQLScalarType<
|
|
172
|
+
GQL_SCALAR_TYPE_NAME extends string,
|
|
173
|
+
SCALAR_TYPE extends boolean|string|number
|
|
174
|
+
> = BrandGraphQL<
|
|
175
|
+
GQL_SCALAR_TYPE_NAME, // 1. Type name
|
|
176
|
+
SCALAR_TYPE, // 2. Super type
|
|
177
|
+
undefined, // 3. Parsed JSON type
|
|
178
|
+
false, // 4. Non-null
|
|
179
|
+
SCALAR_TYPE, // 5. Return type // Needed by GraphQLTypeToResolverResult
|
|
180
|
+
false // 6. Reference
|
|
181
|
+
>
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
//──────────────────────────────────────────────────────────────────────────────
|
|
185
|
+
// Exported functions
|
|
186
|
+
//──────────────────────────────────────────────────────────────────────────────
|
|
187
|
+
export function jsonParse<T extends string>(json: T): GetParsedJson<T> {
|
|
188
|
+
return JSON.parse(json) as GetParsedJson<T>;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export function jsonStringify<T>(value: unknown): T {
|
|
192
|
+
return JSON.stringify(value) as T;
|
|
193
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type {GraphQLArgs} from '../graphQL/InputTypes'
|
|
2
|
+
import type {GraphQLObjectType} from '../graphQL/ObjectTypes'
|
|
3
|
+
import type {GraphQLInterfaceTypeReference} from '../graphQL/ReferenceTypes'
|
|
4
|
+
import type {Fields} from './Field'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export declare interface CreationCallback {
|
|
8
|
+
(params: {
|
|
9
|
+
addFields: (newFields: Fields) => void
|
|
10
|
+
modifyFields: (existingFields: Fields) => void
|
|
11
|
+
removeFields: (existingFields: string[]) => void
|
|
12
|
+
setDescription: (newDescription: string) => void
|
|
13
|
+
setInterfaces: (reWrittenInterfaces: GraphQLInterfaceTypeReference[]) => void
|
|
14
|
+
}): void
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export declare type CreationCallbacks = Record<string, CreationCallback>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
LocalContext,
|
|
3
|
+
LocalContextRecord
|
|
4
|
+
} from '../graphQL/LocalContext'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export declare interface DataFetchingEnvironment<
|
|
8
|
+
ARGS extends Record<string, any> = Record<string, any>,
|
|
9
|
+
LOCAL_CONTEXT extends LocalContextRecord = LocalContextRecord,
|
|
10
|
+
SOURCE = any,
|
|
11
|
+
> {
|
|
12
|
+
args: ARGS
|
|
13
|
+
localContext: LocalContext<LOCAL_CONTEXT>
|
|
14
|
+
source: SOURCE
|
|
15
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type {GraphQLArgs} from '../graphQL/InputTypes'
|
|
2
|
+
import type {GraphQLObjectType} from '../graphQL/ObjectTypes'
|
|
3
|
+
import type {GraphQLObjectTypeReference} from '../graphQL/ReferenceTypes'
|
|
4
|
+
import type {GraphQLScalars} from '../graphQL/ScalarTypes'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export declare interface Field {
|
|
8
|
+
args?: GraphQLArgs
|
|
9
|
+
type:
|
|
10
|
+
| GraphQLScalars
|
|
11
|
+
| GraphQLObjectType
|
|
12
|
+
| GraphQLObjectTypeReference<GraphQLObjectType>
|
|
13
|
+
// | GraphQLEnumType doesn't make sense here?
|
|
14
|
+
// | GraphQLInputType doesn't make sense here.
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export declare type Fields = Record<string, Field>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
GraphQLEnumType,
|
|
3
|
+
GraphQLEnumTypeReference,
|
|
4
|
+
GraphQLInputType,
|
|
5
|
+
GraphQLInputTypeName,
|
|
6
|
+
GraphQLInputTypeReference,
|
|
7
|
+
GraphQLScalars
|
|
8
|
+
} from '../graphQL/'
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export declare type InputTypeField =
|
|
12
|
+
| GraphQLEnumTypeReference<GraphQLEnumType>
|
|
13
|
+
| GraphQLInputTypeReference<GraphQLInputType>
|
|
14
|
+
| GraphQLScalars
|
|
15
|
+
|
|
16
|
+
export declare type InputTypeFields = Record<
|
|
17
|
+
string, // Could make a global InputTypeFieldsMap
|
|
18
|
+
InputTypeField
|
|
19
|
+
>
|
|
20
|
+
|
|
21
|
+
export declare interface InputType {
|
|
22
|
+
description?: string
|
|
23
|
+
fields: InputTypeFields
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export declare type InputTypes = Record<GraphQLInputTypeName,InputType>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type {LocalContextRecord} from '../graphQL/LocalContext'
|
|
2
|
+
import type {DataFetchingEnvironment} from './DataFetchingEnvironment'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export declare interface AnyResolver<
|
|
6
|
+
ARGS extends Record<string, any> = Record<string, any>,
|
|
7
|
+
LOCAL_CONTEXT extends LocalContextRecord = any,
|
|
8
|
+
SOURCE = any,
|
|
9
|
+
RETURN_TYPE = any
|
|
10
|
+
> {
|
|
11
|
+
(env: DataFetchingEnvironment<ARGS,LOCAL_CONTEXT,SOURCE>): RETURN_TYPE
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export declare interface Resolver<
|
|
15
|
+
ARGS extends Record<string, any>,
|
|
16
|
+
LOCAL_CONTEXT extends LocalContextRecord,
|
|
17
|
+
SOURCE,
|
|
18
|
+
RETURN_TYPE
|
|
19
|
+
> {
|
|
20
|
+
(env: DataFetchingEnvironment<ARGS,LOCAL_CONTEXT,SOURCE>): RETURN_TYPE
|
|
21
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference path="./Global.Modifying.d.ts"/>
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
PartialRecord,
|
|
5
|
+
ValueOf,
|
|
6
|
+
} from '../Utils'
|
|
7
|
+
import type {AnyResolver} from './Resolver'
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export declare type Resolvers = PartialRecord<
|
|
11
|
+
keyof GraphQLObjectTypeFieldsMap,
|
|
12
|
+
Record<
|
|
13
|
+
keyof ValueOf<GraphQLObjectTypeFieldsMap>,
|
|
14
|
+
AnyResolver
|
|
15
|
+
>
|
|
16
|
+
>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type {GraphQLObjectTypeName} from '../graphQL/ObjectTypes'
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
// Unions can only reference ObjectTypes.
|
|
5
|
+
// An ObjectType can implement zero or more Interfaces.
|
|
6
|
+
export declare type TypeResolver = (param: any) => GraphQLObjectTypeName
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export declare type TypeResolvers = Record<string, TypeResolver>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
GraphQLInterfaceType,
|
|
3
|
+
GraphQLInterfaceTypeReference,
|
|
4
|
+
GraphQLObjectType,
|
|
5
|
+
} from '../graphQL'
|
|
6
|
+
import type {Fields} from './Field'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export declare interface Type {
|
|
10
|
+
description: string
|
|
11
|
+
fields: Fields
|
|
12
|
+
interfaces: GraphQLInterfaceTypeReference<GraphQLInterfaceType>[]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export declare type Types = Record<string, Type>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
GraphQLObjectType,
|
|
3
|
+
GraphQLObjectTypeReference,
|
|
4
|
+
} from "../graphQL"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export declare interface Union {
|
|
8
|
+
description: string
|
|
9
|
+
types: GraphQLObjectTypeReference<GraphQLObjectType>[]
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export declare type Unions = Record<string, Union>
|