@aws-amplify/api 5.4.5 → 5.4.6-api-v6-models.3f48fe3.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/lib/API.d.ts +18 -2
- package/lib/API.js +103 -1
- package/lib/APIClient.d.ts +46 -0
- package/lib/APIClient.js +336 -0
- package/lib/index.js +6 -6
- package/lib/internals/InternalAPI.d.ts +1 -2
- package/lib/internals/InternalAPI.js +1 -1
- package/lib/internals/index.js +3 -3
- package/lib/tsconfig.build.tsbuildinfo +1 -0
- package/lib/types/index.d.ts +1 -8
- package/lib/types/index.js +4 -4
- package/lib-esm/API.d.ts +18 -2
- package/lib-esm/API.js +103 -2
- package/lib-esm/APIClient.d.ts +46 -0
- package/lib-esm/APIClient.js +329 -0
- package/lib-esm/index.js +0 -1
- package/lib-esm/internals/InternalAPI.d.ts +1 -2
- package/lib-esm/internals/InternalAPI.js +0 -1
- package/lib-esm/internals/index.js +0 -1
- package/lib-esm/tsconfig.build.tsbuildinfo +1 -0
- package/lib-esm/types/index.d.ts +1 -8
- package/lib-esm/types/index.js +0 -1
- package/package.json +17 -12
- package/src/API.ts +153 -2
- package/src/APIClient.ts +436 -0
- package/src/internals/InternalAPI.ts +2 -1
- package/src/types/index.ts +2 -8
- package/lib/.tsbuildinfo +0 -3
- package/lib/API.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/internals/InternalAPI.js.map +0 -1
- package/lib/internals/index.js.map +0 -1
- package/lib/types/index.js.map +0 -1
- package/lib-esm/.tsbuildinfo +0 -3
- package/lib-esm/API.js.map +0 -1
- package/lib-esm/index.js.map +0 -1
- package/lib-esm/internals/InternalAPI.js.map +0 -1
- package/lib-esm/internals/index.js.map +0 -1
- package/lib-esm/types/index.js.map +0 -1
package/src/API.ts
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { AWSAppSyncRealTimeProvider } from '@aws-amplify/pubsub';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
GraphQLOptions,
|
|
6
|
+
GraphQLResult,
|
|
7
|
+
GraphQLQuery,
|
|
8
|
+
GraphQLSubscription,
|
|
9
|
+
} from '@aws-amplify/api-graphql';
|
|
10
|
+
import { graphql as v6graphql } from '@aws-amplify/api-graphql/internals';
|
|
5
11
|
import { Amplify, ConsoleLogger as Logger } from '@aws-amplify/core';
|
|
6
12
|
import Observable from 'zen-observable-ts';
|
|
7
|
-
import { GraphQLQuery, GraphQLSubscription } from './types';
|
|
8
13
|
import { InternalAPIClass } from './internals/InternalAPI';
|
|
14
|
+
import {
|
|
15
|
+
initializeModel,
|
|
16
|
+
generateGraphQLDocument,
|
|
17
|
+
buildGraphQLVariables,
|
|
18
|
+
graphQLOperationsInfo,
|
|
19
|
+
ModelOperation,
|
|
20
|
+
} from './APIClient';
|
|
21
|
+
import type { ModelTypes } from '@aws-amplify/types-package-alpha';
|
|
9
22
|
|
|
10
23
|
const logger = new Logger('API');
|
|
11
24
|
/**
|
|
@@ -42,7 +55,145 @@ export class APIClass extends InternalAPIClass {
|
|
|
42
55
|
): Promise<GraphQLResult<any>> | Observable<object> {
|
|
43
56
|
return super.graphql(options, additionalHeaders);
|
|
44
57
|
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Generates an API client that can work with models or raw GraphQL
|
|
61
|
+
*/
|
|
62
|
+
generateClient<T extends Record<any, any> = never>(): V6Client<T> {
|
|
63
|
+
const config = super.configure({});
|
|
64
|
+
|
|
65
|
+
const { modelIntrospection } = config;
|
|
66
|
+
|
|
67
|
+
const client: V6Client<any> = {
|
|
68
|
+
graphql: v6graphql,
|
|
69
|
+
models: {},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// TODO: refactor this to use separate methods for each CRUDL.
|
|
73
|
+
// Doesn't make sense to gen the methods dynamically given the different args and return values
|
|
74
|
+
for (const model of Object.values(modelIntrospection.models)) {
|
|
75
|
+
const { name } = model as any;
|
|
76
|
+
|
|
77
|
+
client.models[name] = {} as any;
|
|
78
|
+
|
|
79
|
+
Object.entries(graphQLOperationsInfo).forEach(
|
|
80
|
+
([key, { operationPrefix }]) => {
|
|
81
|
+
const operation = key as ModelOperation;
|
|
82
|
+
|
|
83
|
+
if (operation === 'LIST') {
|
|
84
|
+
client.models[name][operationPrefix] = async (args?: any) => {
|
|
85
|
+
const query = generateGraphQLDocument(
|
|
86
|
+
modelIntrospection.models,
|
|
87
|
+
name,
|
|
88
|
+
'LIST',
|
|
89
|
+
args
|
|
90
|
+
);
|
|
91
|
+
const variables = buildGraphQLVariables(
|
|
92
|
+
model,
|
|
93
|
+
'LIST',
|
|
94
|
+
args,
|
|
95
|
+
modelIntrospection
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
console.log('API list', query, variables);
|
|
99
|
+
|
|
100
|
+
const res = (await this.graphql({
|
|
101
|
+
query,
|
|
102
|
+
variables,
|
|
103
|
+
})) as any;
|
|
104
|
+
|
|
105
|
+
// flatten response
|
|
106
|
+
if (res.data !== undefined) {
|
|
107
|
+
const [key] = Object.keys(res.data);
|
|
108
|
+
|
|
109
|
+
if (res.data[key].items) {
|
|
110
|
+
const flattenedResult = res.data[key].items;
|
|
111
|
+
|
|
112
|
+
// don't init if custom selection set
|
|
113
|
+
if (args?.selectionSet) {
|
|
114
|
+
return flattenedResult;
|
|
115
|
+
} else {
|
|
116
|
+
const initialized = initializeModel(
|
|
117
|
+
client,
|
|
118
|
+
name,
|
|
119
|
+
flattenedResult,
|
|
120
|
+
modelIntrospection
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
console.log('initialized', initialized);
|
|
124
|
+
|
|
125
|
+
return initialized;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return res.data[key];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return res as any;
|
|
133
|
+
};
|
|
134
|
+
} else {
|
|
135
|
+
client.models[name][operationPrefix] = async (
|
|
136
|
+
arg?: any,
|
|
137
|
+
options?: any
|
|
138
|
+
) => {
|
|
139
|
+
const query = generateGraphQLDocument(
|
|
140
|
+
modelIntrospection.models,
|
|
141
|
+
name,
|
|
142
|
+
operation
|
|
143
|
+
);
|
|
144
|
+
const variables = buildGraphQLVariables(
|
|
145
|
+
model,
|
|
146
|
+
operation,
|
|
147
|
+
arg,
|
|
148
|
+
modelIntrospection
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
console.log(`API ${operationPrefix}`, query, variables);
|
|
152
|
+
|
|
153
|
+
const res = (await this.graphql({
|
|
154
|
+
query,
|
|
155
|
+
variables,
|
|
156
|
+
})) as any;
|
|
157
|
+
|
|
158
|
+
// flatten response
|
|
159
|
+
if (res.data !== undefined) {
|
|
160
|
+
const [key] = Object.keys(res.data);
|
|
161
|
+
|
|
162
|
+
// TODO: refactor to avoid destructuring here
|
|
163
|
+
const [initialized] = initializeModel(
|
|
164
|
+
client,
|
|
165
|
+
name,
|
|
166
|
+
[res.data[key]],
|
|
167
|
+
modelIntrospection
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
return initialized;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return res;
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return client as V6Client<T>;
|
|
181
|
+
}
|
|
45
182
|
}
|
|
46
183
|
|
|
184
|
+
type FilteredKeys<T> = {
|
|
185
|
+
[P in keyof T]: T[P] extends never ? never : P;
|
|
186
|
+
}[keyof T];
|
|
187
|
+
|
|
188
|
+
type ExcludeNeverFields<O> = {
|
|
189
|
+
[K in FilteredKeys<O>]: O[K];
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
// If no T is passed, ExcludeNeverFields removes "models" from the client
|
|
193
|
+
declare type V6Client<T extends Record<any, any> = never> = ExcludeNeverFields<{
|
|
194
|
+
graphql: typeof v6graphql;
|
|
195
|
+
models: ModelTypes<T>;
|
|
196
|
+
}>;
|
|
197
|
+
|
|
47
198
|
export const API = new APIClass(null);
|
|
48
199
|
Amplify.register(API);
|
package/src/APIClient.ts
ADDED
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { ModelTypes } from '@aws-amplify/types-package-alpha';
|
|
5
|
+
|
|
6
|
+
type ListArgs = { selectionSet?: string[]; filter?: {} };
|
|
7
|
+
|
|
8
|
+
const connectionType = {
|
|
9
|
+
HAS_ONE: 'HAS_ONE',
|
|
10
|
+
HAS_MANY: 'HAS_MANY',
|
|
11
|
+
BELONGS_TO: 'BELONGS_TO',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// TODO: this should accept single result to support CRUD methods; create helper for array/list
|
|
15
|
+
export function initializeModel(
|
|
16
|
+
client: any,
|
|
17
|
+
modelName: string,
|
|
18
|
+
result: any[],
|
|
19
|
+
modelIntrospection: any
|
|
20
|
+
): any[] {
|
|
21
|
+
const introModel = modelIntrospection.models[modelName];
|
|
22
|
+
const introModelFields = introModel.fields;
|
|
23
|
+
|
|
24
|
+
const modelFields: string[] = Object.entries(introModelFields)
|
|
25
|
+
.filter(([_, field]: [string, any]) => field?.type?.model !== undefined)
|
|
26
|
+
.map(([fieldName]) => fieldName);
|
|
27
|
+
|
|
28
|
+
return result.map(record => {
|
|
29
|
+
const initializedRelationalFields = {};
|
|
30
|
+
|
|
31
|
+
for (const field of modelFields) {
|
|
32
|
+
const relatedModelName = introModelFields[field].type.model;
|
|
33
|
+
|
|
34
|
+
const relatedModel = modelIntrospection.models[relatedModelName];
|
|
35
|
+
|
|
36
|
+
const relatedModelPKFieldName =
|
|
37
|
+
relatedModel.primaryKeyInfo.primaryKeyFieldName;
|
|
38
|
+
|
|
39
|
+
const relatedModelSKFieldNames =
|
|
40
|
+
relatedModel.primaryKeyInfo.sortKeyFieldNames;
|
|
41
|
+
|
|
42
|
+
const relationType = introModelFields[field].association.connectionType;
|
|
43
|
+
const connectionFields =
|
|
44
|
+
introModelFields[field].association.associatedWith;
|
|
45
|
+
|
|
46
|
+
const targetNames =
|
|
47
|
+
introModelFields[field].association?.targetNames || [];
|
|
48
|
+
|
|
49
|
+
switch (relationType) {
|
|
50
|
+
case connectionType.HAS_ONE:
|
|
51
|
+
case connectionType.BELONGS_TO:
|
|
52
|
+
const sortKeyValues = relatedModelSKFieldNames.reduce(
|
|
53
|
+
(acc, curVal) => {
|
|
54
|
+
if (record[curVal]) {
|
|
55
|
+
return (acc[curVal] = record[curVal]);
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{}
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
initializedRelationalFields[field] = () => {
|
|
62
|
+
if (record[targetNames[0]]) {
|
|
63
|
+
return client.models[relatedModelName].get({
|
|
64
|
+
[relatedModelPKFieldName]: record[targetNames[0]],
|
|
65
|
+
...sortKeyValues,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return undefined;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
break;
|
|
72
|
+
case connectionType.HAS_MANY:
|
|
73
|
+
const parentPk = introModel.primaryKeyInfo.primaryKeyFieldName;
|
|
74
|
+
const parentSK = introModel.primaryKeyInfo.sortKeyFieldNames;
|
|
75
|
+
|
|
76
|
+
// M:N check - TODO: refactor
|
|
77
|
+
if (relatedModel.fields[connectionFields[0]]?.type.model) {
|
|
78
|
+
const relatedTargetNames =
|
|
79
|
+
relatedModel.fields[connectionFields[0]].association.targetNames;
|
|
80
|
+
|
|
81
|
+
const hasManyFilter = relatedTargetNames.map((field, idx) => {
|
|
82
|
+
if (idx === 0) {
|
|
83
|
+
return { [field]: { eq: record[parentPk] } };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return { [field]: { eq: record[parentSK[idx - 1]] } };
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
initializedRelationalFields[field] = () => {
|
|
90
|
+
if (record[parentPk]) {
|
|
91
|
+
return client.models[relatedModelName].list({
|
|
92
|
+
filter: { and: hasManyFilter },
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return [];
|
|
96
|
+
};
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const hasManyFilter = connectionFields.map((field, idx) => {
|
|
101
|
+
if (idx === 0) {
|
|
102
|
+
return { [field]: { eq: record[parentPk] } };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return { [field]: { eq: record[parentSK[idx - 1]] } };
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
initializedRelationalFields[field] = () => {
|
|
109
|
+
if (record[parentPk]) {
|
|
110
|
+
return client.models[relatedModelName].list({
|
|
111
|
+
filter: { and: hasManyFilter },
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
return [];
|
|
115
|
+
};
|
|
116
|
+
break;
|
|
117
|
+
default:
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return { ...record, ...initializedRelationalFields };
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export const graphQLOperationsInfo = {
|
|
127
|
+
CREATE: { operationPrefix: 'create' as const, usePlural: false },
|
|
128
|
+
READ: { operationPrefix: 'get' as const, usePlural: false },
|
|
129
|
+
UPDATE: { operationPrefix: 'update' as const, usePlural: false },
|
|
130
|
+
DELETE: { operationPrefix: 'delete' as const, usePlural: false },
|
|
131
|
+
LIST: { operationPrefix: 'list' as const, usePlural: true },
|
|
132
|
+
};
|
|
133
|
+
export type ModelOperation = keyof typeof graphQLOperationsInfo;
|
|
134
|
+
|
|
135
|
+
type OperationPrefix =
|
|
136
|
+
(typeof graphQLOperationsInfo)[ModelOperation]['operationPrefix'];
|
|
137
|
+
|
|
138
|
+
const graphQLDocumentsCache = new Map<string, Map<ModelOperation, string>>();
|
|
139
|
+
const SELECTION_SET_ALL_NESTED = '*';
|
|
140
|
+
|
|
141
|
+
function defaultSelectionSetForModel(modelDefinition: any): string {
|
|
142
|
+
const { fields } = modelDefinition;
|
|
143
|
+
return Object.values<any>(fields)
|
|
144
|
+
.map(({ type, name }) => typeof type === 'string' && name) // Default selection set omits model fields
|
|
145
|
+
.filter(Boolean)
|
|
146
|
+
.join(' ');
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function generateSelectionSet(
|
|
150
|
+
modelIntrospection: any,
|
|
151
|
+
modelName: string,
|
|
152
|
+
selectionSet?: string[]
|
|
153
|
+
) {
|
|
154
|
+
const modelDefinition = modelIntrospection[modelName];
|
|
155
|
+
const { fields } = modelDefinition;
|
|
156
|
+
|
|
157
|
+
if (!selectionSet) {
|
|
158
|
+
return defaultSelectionSetForModel(modelDefinition);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const selSet: string[] = [];
|
|
162
|
+
|
|
163
|
+
for (const f of selectionSet) {
|
|
164
|
+
const nested = f.includes('.');
|
|
165
|
+
|
|
166
|
+
if (nested) {
|
|
167
|
+
const [modelFieldName, selectedField] = f.split('.');
|
|
168
|
+
|
|
169
|
+
const relatedModel = fields[modelFieldName]?.type?.model;
|
|
170
|
+
|
|
171
|
+
if (!relatedModel) {
|
|
172
|
+
// TODO: may need to change this to support custom types
|
|
173
|
+
throw Error(`${modelFieldName} is not a model field`);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (selectedField === SELECTION_SET_ALL_NESTED) {
|
|
177
|
+
const relatedModelDefinition = modelIntrospection[relatedModel];
|
|
178
|
+
const defaultSelectionSet = defaultSelectionSetForModel(
|
|
179
|
+
relatedModelDefinition
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
if (fields[modelFieldName]?.isArray) {
|
|
183
|
+
selSet.push(`${modelFieldName} { items { ${defaultSelectionSet} } }`);
|
|
184
|
+
} else {
|
|
185
|
+
selSet.push(`${modelFieldName} { ${defaultSelectionSet} }`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
const exists = Boolean(fields[f]);
|
|
190
|
+
|
|
191
|
+
if (!exists) {
|
|
192
|
+
throw Error(`${f} is not a field of model ${modelName}`);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
selSet.push(f);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return selSet.join(' ');
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export function generateGraphQLDocument(
|
|
203
|
+
modelIntrospection: any,
|
|
204
|
+
modelName: string,
|
|
205
|
+
modelOperation: ModelOperation,
|
|
206
|
+
listArgs?: ListArgs
|
|
207
|
+
): string {
|
|
208
|
+
const modelDefinition = modelIntrospection[modelName];
|
|
209
|
+
|
|
210
|
+
const {
|
|
211
|
+
name,
|
|
212
|
+
pluralName,
|
|
213
|
+
fields,
|
|
214
|
+
primaryKeyInfo: {
|
|
215
|
+
isCustomPrimaryKey,
|
|
216
|
+
primaryKeyFieldName,
|
|
217
|
+
sortKeyFieldNames,
|
|
218
|
+
},
|
|
219
|
+
} = modelDefinition;
|
|
220
|
+
|
|
221
|
+
const { operationPrefix, usePlural } = graphQLOperationsInfo[modelOperation];
|
|
222
|
+
|
|
223
|
+
const { selectionSet } = listArgs || {};
|
|
224
|
+
|
|
225
|
+
const fromCache = graphQLDocumentsCache.get(name)?.get(modelOperation);
|
|
226
|
+
|
|
227
|
+
if (fromCache !== undefined) {
|
|
228
|
+
return fromCache;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (!graphQLDocumentsCache.has(name)) {
|
|
232
|
+
graphQLDocumentsCache.set(name, new Map());
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const graphQLFieldName = `${operationPrefix}${usePlural ? pluralName : name}`;
|
|
236
|
+
let graphQLOperationType: 'mutation' | 'query' | undefined;
|
|
237
|
+
let graphQLSelectionSet: string | undefined;
|
|
238
|
+
let graphQLArguments: Record<string, any> | undefined;
|
|
239
|
+
|
|
240
|
+
const selectionSetFields = generateSelectionSet(
|
|
241
|
+
modelIntrospection,
|
|
242
|
+
modelName,
|
|
243
|
+
selectionSet
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
console.log('generated sel set', selectionSetFields);
|
|
247
|
+
|
|
248
|
+
switch (modelOperation) {
|
|
249
|
+
case 'CREATE':
|
|
250
|
+
case 'UPDATE':
|
|
251
|
+
case 'DELETE':
|
|
252
|
+
graphQLArguments ??
|
|
253
|
+
(graphQLArguments = {
|
|
254
|
+
input: `${
|
|
255
|
+
operationPrefix.charAt(0).toLocaleUpperCase() +
|
|
256
|
+
operationPrefix.slice(1)
|
|
257
|
+
}${name}Input!`,
|
|
258
|
+
});
|
|
259
|
+
graphQLOperationType ?? (graphQLOperationType = 'mutation');
|
|
260
|
+
case 'READ':
|
|
261
|
+
graphQLArguments ??
|
|
262
|
+
(graphQLArguments = isCustomPrimaryKey
|
|
263
|
+
? [primaryKeyFieldName, ...sortKeyFieldNames].reduce(
|
|
264
|
+
(acc, fieldName) => {
|
|
265
|
+
acc[fieldName] = fields[fieldName].type;
|
|
266
|
+
|
|
267
|
+
return acc;
|
|
268
|
+
},
|
|
269
|
+
{}
|
|
270
|
+
)
|
|
271
|
+
: {
|
|
272
|
+
[primaryKeyFieldName]: `${fields[primaryKeyFieldName].type}!`,
|
|
273
|
+
});
|
|
274
|
+
graphQLSelectionSet ?? (graphQLSelectionSet = selectionSetFields);
|
|
275
|
+
case 'LIST':
|
|
276
|
+
graphQLArguments ??
|
|
277
|
+
(graphQLArguments = {
|
|
278
|
+
filter: `Model${name}FilterInput`,
|
|
279
|
+
});
|
|
280
|
+
graphQLOperationType ?? (graphQLOperationType = 'query');
|
|
281
|
+
graphQLSelectionSet ??
|
|
282
|
+
(graphQLSelectionSet = `items { ${selectionSetFields} }`);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const graphQLDocument = `${graphQLOperationType}${
|
|
286
|
+
graphQLArguments
|
|
287
|
+
? `(${Object.entries(graphQLArguments).map(
|
|
288
|
+
([fieldName, type]) => `\$${fieldName}: ${type}`
|
|
289
|
+
)})`
|
|
290
|
+
: ''
|
|
291
|
+
} { ${graphQLFieldName}${
|
|
292
|
+
graphQLArguments
|
|
293
|
+
? `(${Object.keys(graphQLArguments).map(
|
|
294
|
+
fieldName => `${fieldName}: \$${fieldName}`
|
|
295
|
+
)})`
|
|
296
|
+
: ''
|
|
297
|
+
} { ${graphQLSelectionSet} } }`;
|
|
298
|
+
|
|
299
|
+
graphQLDocumentsCache.get(name)?.set(modelOperation, graphQLDocument);
|
|
300
|
+
|
|
301
|
+
return graphQLDocument;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export function buildGraphQLVariables(
|
|
305
|
+
modelDefinition: any,
|
|
306
|
+
operation: ModelOperation,
|
|
307
|
+
arg: any,
|
|
308
|
+
modelIntrospection
|
|
309
|
+
): object {
|
|
310
|
+
const {
|
|
311
|
+
fields,
|
|
312
|
+
primaryKeyInfo: {
|
|
313
|
+
isCustomPrimaryKey,
|
|
314
|
+
primaryKeyFieldName,
|
|
315
|
+
sortKeyFieldNames,
|
|
316
|
+
},
|
|
317
|
+
} = modelDefinition;
|
|
318
|
+
|
|
319
|
+
let variables = {};
|
|
320
|
+
|
|
321
|
+
// TODO: process input
|
|
322
|
+
switch (operation) {
|
|
323
|
+
case 'CREATE':
|
|
324
|
+
variables = {
|
|
325
|
+
input: normalizeMutationInput(arg, modelDefinition, modelIntrospection),
|
|
326
|
+
};
|
|
327
|
+
break;
|
|
328
|
+
case 'UPDATE':
|
|
329
|
+
// readonly fields are not updated
|
|
330
|
+
variables = {
|
|
331
|
+
input: Object.fromEntries(
|
|
332
|
+
Object.entries(
|
|
333
|
+
normalizeMutationInput(arg, modelDefinition, modelIntrospection)
|
|
334
|
+
).filter(([fieldName]) => {
|
|
335
|
+
const { isReadOnly } = fields[fieldName];
|
|
336
|
+
|
|
337
|
+
return !isReadOnly;
|
|
338
|
+
})
|
|
339
|
+
),
|
|
340
|
+
};
|
|
341
|
+
break;
|
|
342
|
+
case 'READ':
|
|
343
|
+
case 'DELETE':
|
|
344
|
+
// only identifiers are sent
|
|
345
|
+
variables = isCustomPrimaryKey
|
|
346
|
+
? [primaryKeyFieldName, ...sortKeyFieldNames].reduce(
|
|
347
|
+
(acc, fieldName) => {
|
|
348
|
+
acc[fieldName] = arg[fieldName];
|
|
349
|
+
|
|
350
|
+
return acc;
|
|
351
|
+
},
|
|
352
|
+
{}
|
|
353
|
+
)
|
|
354
|
+
: { [primaryKeyFieldName]: arg[primaryKeyFieldName] };
|
|
355
|
+
|
|
356
|
+
if (operation === 'DELETE') {
|
|
357
|
+
variables = { input: variables };
|
|
358
|
+
}
|
|
359
|
+
break;
|
|
360
|
+
case 'LIST':
|
|
361
|
+
if (arg?.filter) {
|
|
362
|
+
variables = { filter: arg.filter };
|
|
363
|
+
}
|
|
364
|
+
break;
|
|
365
|
+
default:
|
|
366
|
+
const exhaustiveCheck: never = operation;
|
|
367
|
+
throw new Error(`Unhandled operation case: ${exhaustiveCheck}`);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
return variables;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Iterates over mutation input values and resolves any model inputs to their corresponding join fields/values
|
|
375
|
+
*
|
|
376
|
+
* @example
|
|
377
|
+
* ### Usage
|
|
378
|
+
* ```ts
|
|
379
|
+
* const result = normalizeMutationInput({ post: post }, model, modelDefinition);
|
|
380
|
+
* ```
|
|
381
|
+
* ### Result
|
|
382
|
+
* ```ts
|
|
383
|
+
* { postId: "abc123" }
|
|
384
|
+
* ```
|
|
385
|
+
*
|
|
386
|
+
*/
|
|
387
|
+
export function normalizeMutationInput(
|
|
388
|
+
mutationInput: any,
|
|
389
|
+
model: any,
|
|
390
|
+
modelDefinition: any
|
|
391
|
+
): Record<string, unknown> {
|
|
392
|
+
const { fields } = model;
|
|
393
|
+
|
|
394
|
+
const normalized = {};
|
|
395
|
+
|
|
396
|
+
Object.entries(mutationInput).forEach(([inputFieldName, inputValue]) => {
|
|
397
|
+
const relatedModelName: string | undefined =
|
|
398
|
+
fields[inputFieldName]?.type?.model;
|
|
399
|
+
|
|
400
|
+
if (relatedModelName) {
|
|
401
|
+
const association = fields[inputFieldName]?.association;
|
|
402
|
+
const relatedModelDef = modelDefinition.models[relatedModelName];
|
|
403
|
+
const relatedModelPkInfo = relatedModelDef.primaryKeyInfo;
|
|
404
|
+
|
|
405
|
+
if (association.connectionType === connectionType.HAS_ONE) {
|
|
406
|
+
association.targetNames.forEach((targetName, idx) => {
|
|
407
|
+
const associatedFieldName = association.associatedWith[idx];
|
|
408
|
+
normalized[targetName] = (inputValue as Record<string, unknown>)[
|
|
409
|
+
associatedFieldName
|
|
410
|
+
];
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
if (association.connectionType === connectionType.BELONGS_TO) {
|
|
415
|
+
association.targetNames.forEach((targetName, idx) => {
|
|
416
|
+
if (idx === 0) {
|
|
417
|
+
const associatedFieldName = relatedModelPkInfo.primaryKeyFieldName;
|
|
418
|
+
normalized[targetName] = (inputValue as Record<string, unknown>)[
|
|
419
|
+
associatedFieldName
|
|
420
|
+
];
|
|
421
|
+
} else {
|
|
422
|
+
const associatedFieldName =
|
|
423
|
+
relatedModelPkInfo.sortKeyFieldNames[idx - 1];
|
|
424
|
+
normalized[targetName] = (inputValue as Record<string, unknown>)[
|
|
425
|
+
associatedFieldName
|
|
426
|
+
];
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
} else {
|
|
431
|
+
normalized[inputFieldName] = inputValue;
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
return normalized;
|
|
436
|
+
}
|
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
GraphQLOptions,
|
|
6
6
|
GraphQLResult,
|
|
7
7
|
OperationTypeNode,
|
|
8
|
+
GraphQLQuery,
|
|
9
|
+
GraphQLSubscription,
|
|
8
10
|
} from '@aws-amplify/api-graphql';
|
|
9
11
|
import { InternalGraphQLAPIClass } from '@aws-amplify/api-graphql/internals';
|
|
10
12
|
import { RestAPIClass } from '@aws-amplify/api-rest';
|
|
@@ -20,7 +22,6 @@ import {
|
|
|
20
22
|
} from '@aws-amplify/core';
|
|
21
23
|
import { AWSAppSyncRealTimeProvider } from '@aws-amplify/pubsub';
|
|
22
24
|
import Observable from 'zen-observable-ts';
|
|
23
|
-
import { GraphQLQuery, GraphQLSubscription } from '../types';
|
|
24
25
|
|
|
25
26
|
const logger = new Logger('API');
|
|
26
27
|
/**
|
package/src/types/index.ts
CHANGED
|
@@ -11,12 +11,6 @@ export {
|
|
|
11
11
|
GraphQLAuthError,
|
|
12
12
|
GraphQLResult,
|
|
13
13
|
GRAPHQL_AUTH_MODE,
|
|
14
|
+
GraphQLQuery,
|
|
15
|
+
GraphQLSubscription,
|
|
14
16
|
} from '@aws-amplify/api-graphql';
|
|
15
|
-
|
|
16
|
-
// Opaque type used for determining the graphql query type
|
|
17
|
-
declare const queryType: unique symbol;
|
|
18
|
-
|
|
19
|
-
export type GraphQLQuery<T> = T & { readonly [queryType]: 'query' };
|
|
20
|
-
export type GraphQLSubscription<T> = T & {
|
|
21
|
-
readonly [queryType]: 'subscription';
|
|
22
|
-
};
|
package/lib/.tsbuildinfo
DELETED
package/lib/API.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"API.js","sourceRoot":"","sources":["../src/API.ts"],"names":[],"mappings":";;;AAIA,0CAAqE;AAGrE,uDAA2D;AAE3D,IAAM,MAAM,GAAG,IAAI,oBAAM,CAAC,KAAK,CAAC,CAAC;AACjC;;;;GAIG;AACH;IAA8B,oCAAgB;IAA9C;;IA6BA,CAAC;IA5BO,gCAAa,GAApB;QACC,OAAO,KAAK,CAAC;IACd,CAAC;IAoBD,0BAAO,GAAP,UACC,OAAuB,EACvB,iBAA6C;QAE7C,OAAO,iBAAM,OAAO,YAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;IAClD,CAAC;IACF,eAAC;AAAD,CAAC,AA7BD,CAA8B,8BAAgB,GA6B7C;AA7BY,4BAAQ;AA+BR,QAAA,GAAG,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;AACtC,cAAO,CAAC,QAAQ,CAAC,WAAG,CAAC,CAAC"}
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;AAGtC,6BAAsC;AAA7B,oBAAA,GAAG,CAAA;AAAE,yBAAA,QAAQ,CAAA;AACtB,wDAIkC;AAHjC,yCAAA,gBAAgB,CAAA;AAChB,yCAAA,gBAAgB,CAAA;AAChB,0CAAA,iBAAiB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InternalAPI.js","sourceRoot":"","sources":["../../src/internals/InternalAPI.ts"],"names":[],"mappings":";;;AAQA,gEAA6E;AAC7E,kDAAqD;AACrD,0CAAyC;AACzC,4CAA2C;AAC3C,0CAO2B;AAK3B,IAAM,MAAM,GAAG,IAAI,oBAAM,CAAC,KAAK,CAAC,CAAC;AACjC;;;;GAIG;AACH;IAaC;;;OAGG;IACH,0BAAY,OAAO;QARnB,SAAI,GAAG,WAAI,CAAC;QACZ,UAAK,GAAG,aAAK,CAAC;QACd,gBAAW,GAAG,kBAAW,CAAC;QAOzB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,IAAI,uBAAY,CAAC,OAAO,CAAC,CAAC;QAC1C,IAAI,CAAC,WAAW,GAAG,IAAI,mCAAuB,CAAC,OAAO,CAAC,CAA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AAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/internals/index.ts"],"names":[],"mappings":";;AAAA,qEAAqE;AACrE,sCAAsC;AACtC,6CAA8D;AAArD,oCAAA,WAAW,CAAA;AAAE,yCAAA,gBAAgB,CAAA"}
|
package/lib/types/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC;;;;GAIG;AACH,wDAKkC;AAJjC,yCAAA,gBAAgB,CAAA;AAChB,yCAAA,gBAAgB,CAAA;AAEhB,0CAAA,iBAAiB,CAAA"}
|
package/lib-esm/.tsbuildinfo
DELETED
package/lib-esm/API.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"API.js","sourceRoot":"","sources":["../src/API.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,OAAO,EAAE,aAAa,IAAI,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,IAAM,MAAM,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;AACjC;;;;GAIG;AACH;IAA8B,4BAAgB;IAA9C;;IA6BA,CAAC;IA5BO,gCAAa,GAApB;QACC,OAAO,KAAK,CAAC;IACd,CAAC;IAoBD,0BAAO,GAAP,UACC,OAAuB,EACvB,iBAA6C;QAE7C,OAAO,iBAAM,OAAO,YAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;IAClD,CAAC;IACF,eAAC;AAAD,CAAC,AA7BD,CAA8B,gBAAgB,GA6B7C;;AAED,MAAM,CAAC,IAAM,GAAG,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;AACtC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC"}
|
package/lib-esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAGtC,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EACN,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,GACjB,MAAM,0BAA0B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InternalAPI.js","sourceRoot":"","sources":["../../src/internals/InternalAPI.ts"],"names":[],"mappings":";AAQA,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EACN,OAAO,EACP,SAAS,EACT,QAAQ,EACR,WAAW,EAEX,aAAa,IAAI,MAAM,GACvB,MAAM,mBAAmB,CAAC;AAK3B,IAAM,MAAM,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;AACjC;;;;GAIG;AACH;IAaC;;;OAGG;IACH,0BAAY,OAAO;QARnB,SAAI,GAAG,IAAI,CAAC;QACZ,UAAK,GAAG,KAAK,CAAC;QACd,gBAAW,GAAG,WAAW,CAAC;QAOzB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;QAC1C,IAAI,CAAC,WAAW,GAAG,IAAI,uBAAuB,CAAC,OAAO,CAAC,CAAC;QACxD,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IAEM,wCAAa,GAApB;QACC,OAAO,aAAa,CAAC;IACtB,CAAC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AAW,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC;;;;GAIG;AACH,OAAO,EACN,gBAAgB,EAChB,gBAAgB,EAEhB,iBAAiB,GACjB,MAAM,0BAA0B,CAAC"}
|