@tinacms/graphql 2.0.5 → 2.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/dist/database/util.d.ts +7 -2
- package/dist/index.js +285 -268
- package/dist/resolver/index.d.ts +2 -0
- package/package.json +5 -5
package/dist/database/util.d.ts
CHANGED
|
@@ -3,12 +3,17 @@ import * as yup from 'yup';
|
|
|
3
3
|
import { ContentFormat, ContentFrontmatterFormat } from '@tinacms/schema-tools';
|
|
4
4
|
import { Bridge } from './bridge';
|
|
5
5
|
export { normalizePath };
|
|
6
|
-
export declare const stringifyFile: (content: object, format: ContentFormat | string,
|
|
6
|
+
export declare const stringifyFile: (content: object, format: ContentFormat | string, // FIXME
|
|
7
|
+
/** For non-polymorphic documents we don't need the template key */
|
|
8
|
+
keepTemplateKey: boolean, markdownParseConfig?: {
|
|
7
9
|
frontmatterFormat?: ContentFrontmatterFormat;
|
|
8
10
|
frontmatterDelimiters?: [string, string] | string;
|
|
11
|
+
yamlMaxLineWidth?: number;
|
|
9
12
|
}) => string;
|
|
10
|
-
export declare const parseFile: <T extends object>(content: string, format: ContentFormat | string,
|
|
13
|
+
export declare const parseFile: <T extends object>(content: string, format: ContentFormat | string, // FIXME
|
|
14
|
+
yupSchema: (args: typeof yup) => yup.ObjectSchema<any>, markdownParseConfig?: {
|
|
11
15
|
frontmatterFormat?: ContentFrontmatterFormat;
|
|
16
|
+
lineWidth?: number;
|
|
12
17
|
frontmatterDelimiters?: [string, string] | string;
|
|
13
18
|
}) => T;
|
|
14
19
|
export declare const atob: (b64Encoded: string) => string;
|
package/dist/index.js
CHANGED
|
@@ -3026,7 +3026,7 @@ var validateField = async (field) => {
|
|
|
3026
3026
|
var package_default = {
|
|
3027
3027
|
name: "@tinacms/graphql",
|
|
3028
3028
|
type: "module",
|
|
3029
|
-
version: "2.0
|
|
3029
|
+
version: "2.1.0",
|
|
3030
3030
|
main: "dist/index.js",
|
|
3031
3031
|
module: "./dist/index.js",
|
|
3032
3032
|
files: [
|
|
@@ -3083,7 +3083,7 @@ var package_default = {
|
|
|
3083
3083
|
},
|
|
3084
3084
|
repository: {
|
|
3085
3085
|
url: "https://github.com/tinacms/tinacms.git",
|
|
3086
|
-
directory: "packages/
|
|
3086
|
+
directory: "packages/@tinacms/graphql"
|
|
3087
3087
|
},
|
|
3088
3088
|
devDependencies: {
|
|
3089
3089
|
"@tinacms/schema-tools": "workspace:*",
|
|
@@ -3580,13 +3580,21 @@ var stringifyFile = (content, format, keepTemplateKey, markdownParseConfig) => {
|
|
|
3580
3580
|
case ".markdown":
|
|
3581
3581
|
case ".mdx":
|
|
3582
3582
|
case ".md":
|
|
3583
|
+
const yamlMaxLineWidth = markdownParseConfig?.yamlMaxLineWidth ?? -1;
|
|
3584
|
+
const enginesWithYaml = {
|
|
3585
|
+
...matterEngines,
|
|
3586
|
+
yaml: {
|
|
3587
|
+
parse: (val) => yaml.safeLoad(val),
|
|
3588
|
+
stringify: (val) => yaml.safeDump(val, { lineWidth: yamlMaxLineWidth })
|
|
3589
|
+
}
|
|
3590
|
+
};
|
|
3583
3591
|
const ok = matter.stringify(
|
|
3584
3592
|
typeof $_body === "undefined" ? "" : `
|
|
3585
3593
|
${$_body}`,
|
|
3586
3594
|
strippedContent,
|
|
3587
3595
|
{
|
|
3588
3596
|
language: markdownParseConfig?.frontmatterFormat ?? "yaml",
|
|
3589
|
-
engines:
|
|
3597
|
+
engines: enginesWithYaml,
|
|
3590
3598
|
delimiters: markdownParseConfig?.frontmatterDelimiters ?? "---"
|
|
3591
3599
|
}
|
|
3592
3600
|
);
|
|
@@ -3595,7 +3603,9 @@ ${$_body}`,
|
|
|
3595
3603
|
return JSON.stringify(strippedContent, null, 2);
|
|
3596
3604
|
case ".yaml":
|
|
3597
3605
|
case ".yml":
|
|
3598
|
-
return yaml.safeDump(strippedContent
|
|
3606
|
+
return yaml.safeDump(strippedContent, {
|
|
3607
|
+
lineWidth: markdownParseConfig?.yamlMaxLineWidth ?? -1
|
|
3608
|
+
});
|
|
3599
3609
|
case ".toml":
|
|
3600
3610
|
return toml.stringify(strippedContent);
|
|
3601
3611
|
default:
|
|
@@ -6055,6 +6065,7 @@ var resolve = async ({
|
|
|
6055
6065
|
tinaSchema,
|
|
6056
6066
|
isAudit: isAudit || false
|
|
6057
6067
|
});
|
|
6068
|
+
const resolverPromises = [];
|
|
6058
6069
|
const res = await graphql({
|
|
6059
6070
|
schema: graphQLSchema,
|
|
6060
6071
|
source: query,
|
|
@@ -6072,302 +6083,307 @@ var resolve = async ({
|
|
|
6072
6083
|
throw new Error(`Unable to find lookup key for ${namedType}`);
|
|
6073
6084
|
},
|
|
6074
6085
|
fieldResolver: async (source = {}, args = {}, _context, info) => {
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6086
|
+
const fieldPromise = (async () => {
|
|
6087
|
+
try {
|
|
6088
|
+
const returnType = getNamedType(info.returnType).toString();
|
|
6089
|
+
if (returnType === "Collection") {
|
|
6090
|
+
const possibleCollectionValue = source[info.fieldName];
|
|
6091
|
+
if (possibleCollectionValue) {
|
|
6092
|
+
return possibleCollectionValue;
|
|
6093
|
+
}
|
|
6094
|
+
if (info.fieldName === "collections") {
|
|
6095
|
+
return handleCollectionsField(info, tinaSchema, resolver, args);
|
|
6096
|
+
}
|
|
6097
|
+
return handleCollectionField(info, args, resolver);
|
|
6081
6098
|
}
|
|
6082
|
-
if (info.fieldName === "
|
|
6083
|
-
return
|
|
6099
|
+
if (info.fieldName === "getOptimizedQuery") {
|
|
6100
|
+
return args.queryString || "";
|
|
6084
6101
|
}
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
}
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
switch (lookup.resolveType) {
|
|
6128
|
-
/*
|
|
6129
|
-
* `node(id: $id)`
|
|
6130
|
-
*/
|
|
6131
|
-
case "nodeDocument":
|
|
6132
|
-
assertShape(
|
|
6133
|
-
args,
|
|
6134
|
-
(yup3) => yup3.object({ id: yup3.string().required() })
|
|
6135
|
-
);
|
|
6136
|
-
return resolver.getDocument(args.id);
|
|
6137
|
-
case "multiCollectionDocument":
|
|
6138
|
-
const possibleValue = source[info.fieldName];
|
|
6139
|
-
if (typeof possibleValue === "string" && possibleValue !== "") {
|
|
6140
|
-
return resolver.getDocument(possibleValue);
|
|
6141
|
-
}
|
|
6142
|
-
if ([
|
|
6143
|
-
NAMER.documentQueryName(),
|
|
6144
|
-
"addPendingDocument",
|
|
6145
|
-
"createDocument",
|
|
6146
|
-
"updateDocument",
|
|
6147
|
-
"deleteDocument",
|
|
6148
|
-
"createFolder"
|
|
6149
|
-
].includes(info.fieldName)) {
|
|
6102
|
+
if (info.fieldName === "authenticate") {
|
|
6103
|
+
const authArgs = args;
|
|
6104
|
+
return handleAuthenticate({
|
|
6105
|
+
tinaSchema,
|
|
6106
|
+
resolver,
|
|
6107
|
+
sub: authArgs.sub,
|
|
6108
|
+
password: authArgs.password,
|
|
6109
|
+
info,
|
|
6110
|
+
ctxUser
|
|
6111
|
+
});
|
|
6112
|
+
}
|
|
6113
|
+
if (info.fieldName === "authorize") {
|
|
6114
|
+
const authArgs = args;
|
|
6115
|
+
return handleAuthorize({
|
|
6116
|
+
tinaSchema,
|
|
6117
|
+
resolver,
|
|
6118
|
+
sub: authArgs.sub,
|
|
6119
|
+
info,
|
|
6120
|
+
ctxUser
|
|
6121
|
+
});
|
|
6122
|
+
}
|
|
6123
|
+
if (info.fieldName === "updatePassword") {
|
|
6124
|
+
const authArgs = args;
|
|
6125
|
+
return handleUpdatePassword({
|
|
6126
|
+
tinaSchema,
|
|
6127
|
+
resolver,
|
|
6128
|
+
password: authArgs.password,
|
|
6129
|
+
info,
|
|
6130
|
+
ctxUser
|
|
6131
|
+
});
|
|
6132
|
+
}
|
|
6133
|
+
const lookup = await database.getLookup(returnType);
|
|
6134
|
+
if (!lookup) {
|
|
6135
|
+
return source[info.fieldName];
|
|
6136
|
+
}
|
|
6137
|
+
const isCreation = lookup[info.fieldName] === "create";
|
|
6138
|
+
const isMutation = info.parentType.toString() === "Mutation";
|
|
6139
|
+
switch (lookup.resolveType) {
|
|
6140
|
+
/*
|
|
6141
|
+
* `node(id: $id)`
|
|
6142
|
+
*/
|
|
6143
|
+
case "nodeDocument":
|
|
6150
6144
|
assertShape(
|
|
6151
6145
|
args,
|
|
6152
|
-
(yup3) => yup3.object({
|
|
6153
|
-
collection: yup3.string().required(),
|
|
6154
|
-
relativePath: yup3.string().required()
|
|
6155
|
-
})
|
|
6146
|
+
(yup3) => yup3.object({ id: yup3.string().required() })
|
|
6156
6147
|
);
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6148
|
+
return resolver.getDocument(args.id);
|
|
6149
|
+
case "multiCollectionDocument":
|
|
6150
|
+
const possibleValue = source[info.fieldName];
|
|
6151
|
+
if (typeof possibleValue === "string" && possibleValue !== "") {
|
|
6152
|
+
return resolver.getDocument(possibleValue);
|
|
6153
|
+
}
|
|
6154
|
+
if ([
|
|
6155
|
+
NAMER.documentQueryName(),
|
|
6156
|
+
"addPendingDocument",
|
|
6157
|
+
"createDocument",
|
|
6158
|
+
"updateDocument",
|
|
6159
|
+
"deleteDocument",
|
|
6160
|
+
"createFolder"
|
|
6161
|
+
].includes(info.fieldName)) {
|
|
6162
|
+
assertShape(
|
|
6163
|
+
args,
|
|
6164
|
+
(yup3) => yup3.object({
|
|
6165
|
+
collection: yup3.string().required(),
|
|
6166
|
+
relativePath: yup3.string().required()
|
|
6167
|
+
})
|
|
6168
|
+
);
|
|
6169
|
+
if (isMutation) {
|
|
6170
|
+
switch (info.fieldName) {
|
|
6171
|
+
case "addPendingDocument":
|
|
6172
|
+
return resolver.resolveAddPendingDocument({
|
|
6173
|
+
collectionName: args.collection,
|
|
6174
|
+
relativePath: args.relativePath,
|
|
6175
|
+
templateName: args.template
|
|
6176
|
+
});
|
|
6177
|
+
case "createFolder":
|
|
6178
|
+
return resolver.resolveCreateFolder({
|
|
6179
|
+
collectionName: args.collection,
|
|
6180
|
+
relativePath: args.relativePath
|
|
6181
|
+
});
|
|
6182
|
+
case "createDocument": {
|
|
6183
|
+
assertShape(
|
|
6184
|
+
args,
|
|
6185
|
+
(yup3) => yup3.object({
|
|
6186
|
+
params: yup3.object().shape({
|
|
6187
|
+
[args.collection]: yup3.object().required()
|
|
6188
|
+
}).required()
|
|
6189
|
+
})
|
|
6190
|
+
);
|
|
6191
|
+
return resolver.resolveCreateDocument({
|
|
6192
|
+
collectionName: args.collection,
|
|
6193
|
+
relativePath: args.relativePath,
|
|
6194
|
+
body: args.params[args.collection]
|
|
6195
|
+
});
|
|
6196
|
+
}
|
|
6197
|
+
case "updateDocument": {
|
|
6198
|
+
assertShape(
|
|
6199
|
+
args,
|
|
6200
|
+
(yup3) => yup3.object({
|
|
6201
|
+
params: yup3.object().shape({
|
|
6202
|
+
relativePath: yup3.string().optional()
|
|
6203
|
+
}).required()
|
|
6204
|
+
})
|
|
6205
|
+
);
|
|
6206
|
+
const newRelativePath = args.params.relativePath;
|
|
6207
|
+
const newBody = args.params[args.collection];
|
|
6208
|
+
return resolver.resolveUpdateDocument({
|
|
6209
|
+
collectionName: args.collection,
|
|
6210
|
+
relativePath: args.relativePath,
|
|
6211
|
+
newRelativePath,
|
|
6212
|
+
newBody
|
|
6213
|
+
});
|
|
6214
|
+
}
|
|
6215
|
+
case "deleteDocument":
|
|
6216
|
+
return resolver.resolveDeleteDocument({
|
|
6217
|
+
collectionName: args.collection,
|
|
6218
|
+
relativePath: args.relativePath
|
|
6219
|
+
});
|
|
6202
6220
|
}
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6221
|
+
} else if (info.fieldName === NAMER.documentQueryName()) {
|
|
6222
|
+
return resolver.resolveRetrievedDocument({
|
|
6223
|
+
collectionName: args.collection,
|
|
6224
|
+
relativePath: args.relativePath
|
|
6225
|
+
});
|
|
6208
6226
|
}
|
|
6209
|
-
}
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
|
|
6227
|
+
}
|
|
6228
|
+
return possibleValue;
|
|
6229
|
+
/*
|
|
6230
|
+
* eg `getMovieDocument.data.actors`
|
|
6231
|
+
*/
|
|
6232
|
+
case "multiCollectionDocumentList":
|
|
6233
|
+
const listValue = source[info.fieldName];
|
|
6234
|
+
if (Array.isArray(listValue)) {
|
|
6235
|
+
return {
|
|
6236
|
+
totalCount: listValue.length,
|
|
6237
|
+
edges: listValue.map((document) => {
|
|
6238
|
+
return { node: document };
|
|
6239
|
+
})
|
|
6240
|
+
};
|
|
6241
|
+
}
|
|
6242
|
+
if (info.fieldName === "documents" && listValue?.collection && listValue?.hasDocuments) {
|
|
6243
|
+
const documentsArgs = args;
|
|
6244
|
+
const collectionName = listValue.collection?.name;
|
|
6245
|
+
const filter = (collectionName && documentsArgs.filter?.[collectionName]) ?? documentsArgs.filter;
|
|
6246
|
+
return resolver.resolveCollectionConnection({
|
|
6247
|
+
args: {
|
|
6248
|
+
...documentsArgs,
|
|
6249
|
+
filter
|
|
6250
|
+
},
|
|
6251
|
+
collection: listValue.collection
|
|
6213
6252
|
});
|
|
6214
6253
|
}
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
if (info.fieldName === "documents" && listValue?.collection && listValue?.hasDocuments) {
|
|
6231
|
-
const documentsArgs = args;
|
|
6232
|
-
const collectionName = listValue.collection?.name;
|
|
6233
|
-
const filter = (collectionName && documentsArgs.filter?.[collectionName]) ?? documentsArgs.filter;
|
|
6234
|
-
return resolver.resolveCollectionConnection({
|
|
6235
|
-
args: {
|
|
6236
|
-
...documentsArgs,
|
|
6237
|
-
filter
|
|
6238
|
-
},
|
|
6239
|
-
collection: listValue.collection
|
|
6240
|
-
});
|
|
6241
|
-
}
|
|
6242
|
-
throw new Error(
|
|
6243
|
-
`Expected an array for result of ${info.fieldName} at ${info.path}`
|
|
6244
|
-
);
|
|
6245
|
-
/*
|
|
6246
|
-
* Collections-specific getter
|
|
6247
|
-
* eg. `getPostDocument`/`createPostDocument`/`updatePostDocument`
|
|
6248
|
-
*
|
|
6249
|
-
* if coming from a query result
|
|
6250
|
-
* the field will be `node`
|
|
6251
|
-
*/
|
|
6252
|
-
case "collectionDocument": {
|
|
6253
|
-
const possibleDocValue = source[info.fieldName];
|
|
6254
|
-
if (possibleDocValue) {
|
|
6255
|
-
return possibleDocValue;
|
|
6256
|
-
}
|
|
6257
|
-
assertShape(
|
|
6258
|
-
args,
|
|
6259
|
-
(yup3) => yup3.object({
|
|
6260
|
-
relativePath: yup3.string().required()
|
|
6261
|
-
})
|
|
6262
|
-
);
|
|
6263
|
-
if (isMutation) {
|
|
6254
|
+
throw new Error(
|
|
6255
|
+
`Expected an array for result of ${info.fieldName} at ${info.path}`
|
|
6256
|
+
);
|
|
6257
|
+
/*
|
|
6258
|
+
* Collections-specific getter
|
|
6259
|
+
* eg. `getPostDocument`/`createPostDocument`/`updatePostDocument`
|
|
6260
|
+
*
|
|
6261
|
+
* if coming from a query result
|
|
6262
|
+
* the field will be `node`
|
|
6263
|
+
*/
|
|
6264
|
+
case "collectionDocument": {
|
|
6265
|
+
const possibleDocValue = source[info.fieldName];
|
|
6266
|
+
if (possibleDocValue) {
|
|
6267
|
+
return possibleDocValue;
|
|
6268
|
+
}
|
|
6264
6269
|
assertShape(
|
|
6265
6270
|
args,
|
|
6266
6271
|
(yup3) => yup3.object({
|
|
6267
|
-
|
|
6272
|
+
relativePath: yup3.string().required()
|
|
6268
6273
|
})
|
|
6269
6274
|
);
|
|
6270
|
-
if (
|
|
6271
|
-
return resolver.resolveCreateDocument({
|
|
6272
|
-
collectionName: lookup.collection,
|
|
6273
|
-
relativePath: args.relativePath,
|
|
6274
|
-
body: args.params
|
|
6275
|
-
});
|
|
6276
|
-
} else {
|
|
6277
|
-
return resolver.resolveUpdateDocument({
|
|
6278
|
-
collectionName: lookup.collection,
|
|
6279
|
-
relativePath: args.relativePath,
|
|
6280
|
-
newBody: args.params
|
|
6281
|
-
});
|
|
6282
|
-
}
|
|
6283
|
-
} else {
|
|
6284
|
-
return resolver.resolveRetrievedDocument({
|
|
6285
|
-
collectionName: lookup.collection,
|
|
6286
|
-
relativePath: args.relativePath
|
|
6287
|
-
});
|
|
6288
|
-
}
|
|
6289
|
-
}
|
|
6290
|
-
/*
|
|
6291
|
-
* Collections-specific list getter
|
|
6292
|
-
* eg. `getPageList`
|
|
6293
|
-
*/
|
|
6294
|
-
case "collectionDocumentList":
|
|
6295
|
-
const collectionArgs = args;
|
|
6296
|
-
return resolver.resolveCollectionConnection({
|
|
6297
|
-
args: collectionArgs,
|
|
6298
|
-
collection: tinaSchema.getCollection(lookup.collection)
|
|
6299
|
-
});
|
|
6300
|
-
/*
|
|
6301
|
-
* A polymorphic data set, it can be from a document's data
|
|
6302
|
-
* of any nested object which can be one of many shapes
|
|
6303
|
-
*
|
|
6304
|
-
* ```graphql
|
|
6305
|
-
* getPostDocument(relativePath: $relativePath) {
|
|
6306
|
-
* data {...} <- this part
|
|
6307
|
-
* }
|
|
6308
|
-
* ```
|
|
6309
|
-
* ```graphql
|
|
6310
|
-
* getBlockDocument(relativePath: $relativePath) {
|
|
6311
|
-
* data {
|
|
6312
|
-
* blocks {...} <- or this part
|
|
6313
|
-
* }
|
|
6314
|
-
* }
|
|
6315
|
-
* ```
|
|
6316
|
-
*/
|
|
6317
|
-
case "unionData":
|
|
6318
|
-
const unionValue = source[info.fieldName];
|
|
6319
|
-
if (!unionValue) {
|
|
6320
|
-
const unionArgs = args;
|
|
6321
|
-
if (unionArgs.relativePath) {
|
|
6275
|
+
if (isMutation) {
|
|
6322
6276
|
assertShape(
|
|
6323
6277
|
args,
|
|
6324
6278
|
(yup3) => yup3.object({
|
|
6325
|
-
|
|
6279
|
+
params: yup3.object().required()
|
|
6326
6280
|
})
|
|
6327
6281
|
);
|
|
6328
|
-
if (
|
|
6282
|
+
if (isCreation) {
|
|
6283
|
+
return resolver.resolveCreateDocument({
|
|
6284
|
+
collectionName: lookup.collection,
|
|
6285
|
+
relativePath: args.relativePath,
|
|
6286
|
+
body: args.params
|
|
6287
|
+
});
|
|
6288
|
+
} else {
|
|
6289
|
+
return resolver.resolveUpdateDocument({
|
|
6290
|
+
collectionName: lookup.collection,
|
|
6291
|
+
relativePath: args.relativePath,
|
|
6292
|
+
newBody: args.params
|
|
6293
|
+
});
|
|
6294
|
+
}
|
|
6295
|
+
} else {
|
|
6296
|
+
return resolver.resolveRetrievedDocument({
|
|
6297
|
+
collectionName: lookup.collection,
|
|
6298
|
+
relativePath: args.relativePath
|
|
6299
|
+
});
|
|
6300
|
+
}
|
|
6301
|
+
}
|
|
6302
|
+
/*
|
|
6303
|
+
* Collections-specific list getter
|
|
6304
|
+
* eg. `getPageList`
|
|
6305
|
+
*/
|
|
6306
|
+
case "collectionDocumentList":
|
|
6307
|
+
const collectionArgs = args;
|
|
6308
|
+
return resolver.resolveCollectionConnection({
|
|
6309
|
+
args: collectionArgs,
|
|
6310
|
+
collection: tinaSchema.getCollection(lookup.collection)
|
|
6311
|
+
});
|
|
6312
|
+
/*
|
|
6313
|
+
* A polymorphic data set, it can be from a document's data
|
|
6314
|
+
* of any nested object which can be one of many shapes
|
|
6315
|
+
*
|
|
6316
|
+
* ```graphql
|
|
6317
|
+
* getPostDocument(relativePath: $relativePath) {
|
|
6318
|
+
* data {...} <- this part
|
|
6319
|
+
* }
|
|
6320
|
+
* ```
|
|
6321
|
+
* ```graphql
|
|
6322
|
+
* getBlockDocument(relativePath: $relativePath) {
|
|
6323
|
+
* data {
|
|
6324
|
+
* blocks {...} <- or this part
|
|
6325
|
+
* }
|
|
6326
|
+
* }
|
|
6327
|
+
* ```
|
|
6328
|
+
*/
|
|
6329
|
+
case "unionData":
|
|
6330
|
+
const unionValue = source[info.fieldName];
|
|
6331
|
+
if (!unionValue) {
|
|
6332
|
+
const unionArgs = args;
|
|
6333
|
+
if (unionArgs.relativePath) {
|
|
6329
6334
|
assertShape(
|
|
6330
6335
|
args,
|
|
6331
6336
|
(yup3) => yup3.object({
|
|
6332
|
-
|
|
6337
|
+
relativePath: yup3.string().required()
|
|
6333
6338
|
})
|
|
6334
6339
|
);
|
|
6335
|
-
if (
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
|
|
6340
|
+
if (isMutation) {
|
|
6341
|
+
assertShape(
|
|
6342
|
+
args,
|
|
6343
|
+
(yup3) => yup3.object({
|
|
6344
|
+
params: yup3.object().required()
|
|
6345
|
+
})
|
|
6346
|
+
);
|
|
6347
|
+
if (isCreation) {
|
|
6348
|
+
return resolver.resolveCreateDocument({
|
|
6349
|
+
collectionName: lookup.collection,
|
|
6350
|
+
relativePath: args.relativePath,
|
|
6351
|
+
body: args.params
|
|
6352
|
+
});
|
|
6353
|
+
} else {
|
|
6354
|
+
return resolver.resolveUpdateDocument({
|
|
6355
|
+
collectionName: lookup.collection,
|
|
6356
|
+
relativePath: args.relativePath,
|
|
6357
|
+
newBody: args.params
|
|
6358
|
+
});
|
|
6359
|
+
}
|
|
6341
6360
|
} else {
|
|
6342
|
-
return resolver.
|
|
6361
|
+
return resolver.resolveRetrievedDocument({
|
|
6343
6362
|
collectionName: lookup.collection,
|
|
6344
|
-
relativePath: args.relativePath
|
|
6345
|
-
newBody: args.params
|
|
6363
|
+
relativePath: args.relativePath
|
|
6346
6364
|
});
|
|
6347
6365
|
}
|
|
6348
|
-
} else {
|
|
6349
|
-
return resolver.resolveRetrievedDocument({
|
|
6350
|
-
collectionName: lookup.collection,
|
|
6351
|
-
relativePath: args.relativePath
|
|
6352
|
-
});
|
|
6353
6366
|
}
|
|
6354
6367
|
}
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6368
|
+
return unionValue;
|
|
6369
|
+
default:
|
|
6370
|
+
console.error(
|
|
6371
|
+
`Could not recognize resolve type '${lookup.resolveType}'.`
|
|
6372
|
+
);
|
|
6373
|
+
console.error(
|
|
6374
|
+
"The field resolver needs to be updated to handle this new type."
|
|
6375
|
+
);
|
|
6376
|
+
throw new Error("Unexpected resolve type");
|
|
6377
|
+
}
|
|
6378
|
+
} catch (e) {
|
|
6379
|
+
handleFetchErrorError(e, verboseValue);
|
|
6365
6380
|
}
|
|
6366
|
-
}
|
|
6367
|
-
|
|
6368
|
-
|
|
6381
|
+
})();
|
|
6382
|
+
resolverPromises.push(fieldPromise);
|
|
6383
|
+
return fieldPromise;
|
|
6369
6384
|
}
|
|
6370
6385
|
});
|
|
6386
|
+
await Promise.allSettled(resolverPromises);
|
|
6371
6387
|
if (res.errors) {
|
|
6372
6388
|
if (!silenceErrors) {
|
|
6373
6389
|
res.errors.map((e) => {
|
|
@@ -6968,7 +6984,8 @@ var Database = class {
|
|
|
6968
6984
|
//templateInfo.type === 'union',
|
|
6969
6985
|
{
|
|
6970
6986
|
frontmatterFormat: collection?.frontmatterFormat,
|
|
6971
|
-
frontmatterDelimiters: collection?.frontmatterDelimiters
|
|
6987
|
+
frontmatterDelimiters: collection?.frontmatterDelimiters,
|
|
6988
|
+
yamlMaxLineWidth: collection?.yamlMaxLineWidth
|
|
6972
6989
|
}
|
|
6973
6990
|
);
|
|
6974
6991
|
};
|
package/dist/resolver/index.d.ts
CHANGED
|
@@ -79,6 +79,7 @@ export declare class Resolver {
|
|
|
79
79
|
defaultItem?: import("@tinacms/schema-tools").DefaultItem<Record<string, any>>;
|
|
80
80
|
frontmatterFormat?: import("@tinacms/schema-tools").ContentFrontmatterFormat;
|
|
81
81
|
frontmatterDelimiters?: [string, string] | string;
|
|
82
|
+
yamlMaxLineWidth?: number;
|
|
82
83
|
match?: {
|
|
83
84
|
include?: string;
|
|
84
85
|
exclude?: string;
|
|
@@ -107,6 +108,7 @@ export declare class Resolver {
|
|
|
107
108
|
defaultItem?: import("@tinacms/schema-tools").DefaultItem<Record<string, any>>;
|
|
108
109
|
frontmatterFormat?: import("@tinacms/schema-tools").ContentFrontmatterFormat;
|
|
109
110
|
frontmatterDelimiters?: [string, string] | string;
|
|
111
|
+
yamlMaxLineWidth?: number;
|
|
110
112
|
match?: {
|
|
111
113
|
include?: string;
|
|
112
114
|
exclude?: string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/graphql",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
7
7
|
"files": [
|
|
@@ -43,15 +43,15 @@
|
|
|
43
43
|
"normalize-path": "^3.0.0",
|
|
44
44
|
"readable-stream": "^4.7.0",
|
|
45
45
|
"yup": "^1.6.1",
|
|
46
|
-
"@tinacms/mdx": "2.0.
|
|
47
|
-
"@tinacms/schema-tools": "2.
|
|
46
|
+
"@tinacms/mdx": "2.0.4",
|
|
47
|
+
"@tinacms/schema-tools": "2.4.0"
|
|
48
48
|
},
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"registry": "https://registry.npmjs.org"
|
|
51
51
|
},
|
|
52
52
|
"repository": {
|
|
53
53
|
"url": "https://github.com/tinacms/tinacms.git",
|
|
54
|
-
"directory": "packages/
|
|
54
|
+
"directory": "packages/@tinacms/graphql"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/cors": "^2.8.17",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"vite": "^4.5.9",
|
|
72
72
|
"vitest": "^0.32.4",
|
|
73
73
|
"zod": "^3.24.2",
|
|
74
|
-
"@tinacms/schema-tools": "2.
|
|
74
|
+
"@tinacms/schema-tools": "2.4.0",
|
|
75
75
|
"@tinacms/scripts": "1.4.2"
|
|
76
76
|
},
|
|
77
77
|
"scripts": {
|