Add parentKeySelector
This commit is contained in:
Родитель
a593a9f104
Коммит
265af782a3
|
@ -61,9 +61,7 @@ const requestContract = createRequestContract({
|
||||||
uriFactoryFn: urlDecorator(odataUrlFactory),
|
uriFactoryFn: urlDecorator(odataUrlFactory),
|
||||||
headerFactoryFn: headerDecorator(odataHeaderFactory),
|
headerFactoryFn: headerDecorator(odataHeaderFactory),
|
||||||
payloadFactoryFn: payloadDecorator(odataPayloadFactory),
|
payloadFactoryFn: payloadDecorator(odataPayloadFactory),
|
||||||
|
parentKeySelector: variables => variables.locator.descriptor.<%- parentKey %>,
|
||||||
// TODO: figure out how to do parentKey
|
|
||||||
parentKeySelector: variables => variables.locator.descriptor.<%- parentKey %>
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const responseContract = createResponseContract({
|
const responseContract = createResponseContract({
|
||||||
|
|
|
@ -54,6 +54,7 @@ const requestContract = createRequestContract({
|
||||||
fetchPolicy: networkPolicy,
|
fetchPolicy: networkPolicy,
|
||||||
uriFactoryFn: urlDecorator(odataUrlFactory),
|
uriFactoryFn: urlDecorator(odataUrlFactory),
|
||||||
headerFactoryFn: headerDecorator(odataHeaderFactory),
|
headerFactoryFn: headerDecorator(odataHeaderFactory),
|
||||||
|
parentKeySelector: variables => variables.locator.descriptor.<%- parentKey %>,
|
||||||
});
|
});
|
||||||
|
|
||||||
const responseContract = createResponseContract({
|
const responseContract = createResponseContract({
|
||||||
|
|
|
@ -61,6 +61,7 @@ const requestContract = createRequestContract({
|
||||||
uriFactoryFn: urlDecorator(odataUrlFactory),
|
uriFactoryFn: urlDecorator(odataUrlFactory),
|
||||||
headerFactoryFn: headerDecorator(odataHeaderFactory),
|
headerFactoryFn: headerDecorator(odataHeaderFactory),
|
||||||
payloadFactoryFn: payloadDecorator(odataPayloadFactory),
|
payloadFactoryFn: payloadDecorator(odataPayloadFactory),
|
||||||
|
parentKeySelector: variables => variables.locator.descriptor.<%- parentKey %>,
|
||||||
});
|
});
|
||||||
|
|
||||||
const responseContract = createResponseContract({
|
const responseContract = createResponseContract({
|
||||||
|
|
|
@ -54,6 +54,7 @@ const requestContract = createRequestContract({
|
||||||
fetchPolicy: networkPolicy,
|
fetchPolicy: networkPolicy,
|
||||||
uriFactoryFn: urlDecorator(odataUrlFactory),
|
uriFactoryFn: urlDecorator(odataUrlFactory),
|
||||||
headerFactoryFn: headerDecorator(odataHeaderFactory),
|
headerFactoryFn: headerDecorator(odataHeaderFactory),
|
||||||
|
parentKeySelector: variables => variables.locator.descriptor.<%- parentKey %>,
|
||||||
});
|
});
|
||||||
|
|
||||||
const responseContract = createResponseContract({
|
const responseContract = createResponseContract({
|
||||||
|
|
|
@ -54,6 +54,7 @@ const requestContract = createRequestContract({
|
||||||
fetchPolicy: networkPolicy,
|
fetchPolicy: networkPolicy,
|
||||||
uriFactoryFn: urlDecorator(odataUrlFactory),
|
uriFactoryFn: urlDecorator(odataUrlFactory),
|
||||||
headerFactoryFn: headerDecorator(odataHeaderFactory),
|
headerFactoryFn: headerDecorator(odataHeaderFactory),
|
||||||
|
parentKeySelector: variables => variables.locator.descriptor.<%- parentKey %>,
|
||||||
});
|
});
|
||||||
|
|
||||||
const responseContract = createResponseContract({
|
const responseContract = createResponseContract({
|
||||||
|
|
|
@ -61,6 +61,7 @@ const requestContract = createRequestContract({
|
||||||
uriFactoryFn: urlDecorator(odataUrlFactory),
|
uriFactoryFn: urlDecorator(odataUrlFactory),
|
||||||
headerFactoryFn: headerDecorator(odataHeaderFactory),
|
headerFactoryFn: headerDecorator(odataHeaderFactory),
|
||||||
payloadFactoryFn: payloadDecorator(odataPayloadFactory),
|
payloadFactoryFn: payloadDecorator(odataPayloadFactory),
|
||||||
|
parentKeySelector: variables => variables.locator.descriptor.<%- parentKey %>,
|
||||||
});
|
});
|
||||||
|
|
||||||
const responseContract = createResponseContract({
|
const responseContract = createResponseContract({
|
||||||
|
|
|
@ -54,6 +54,7 @@ const requestContract = createRequestContract({
|
||||||
fetchPolicy: networkPolicy,
|
fetchPolicy: networkPolicy,
|
||||||
uriFactoryFn: urlDecorator(odataUrlFactory),
|
uriFactoryFn: urlDecorator(odataUrlFactory),
|
||||||
headerFactoryFn: headerDecorator(odataHeaderFactory),
|
headerFactoryFn: headerDecorator(odataHeaderFactory),
|
||||||
|
parentKeySelector: variables => variables.locator.descriptor.<%- parentKey %>,
|
||||||
});
|
});
|
||||||
|
|
||||||
const responseContract = createResponseContract({
|
const responseContract = createResponseContract({
|
||||||
|
|
|
@ -61,6 +61,7 @@ const responseContract = createResponseContract({
|
||||||
responseType: responseTypes.ENTITY,
|
responseType: responseTypes.ENTITY,
|
||||||
keySelector: keySelectorDecorator(r => r.<%= key %>),
|
keySelector: keySelectorDecorator(r => r.<%= key %>),
|
||||||
processorFn: processorDecorator(r => r),
|
processorFn: processorDecorator(r => r),
|
||||||
|
parentKeySelector: variables => variables.locator.descriptor.<%- parentKey %>,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const fetchSpec = createSpec(
|
export const fetchSpec = createSpec(
|
||||||
|
|
|
@ -61,6 +61,7 @@ const requestContract = createRequestContract({
|
||||||
uriFactoryFn: urlDecorator(odataUrlFactory),
|
uriFactoryFn: urlDecorator(odataUrlFactory),
|
||||||
headerFactoryFn: headerDecorator(odataHeaderFactory),
|
headerFactoryFn: headerDecorator(odataHeaderFactory),
|
||||||
payloadFactoryFn: payloadDecorator(odataPayloadFactory),
|
payloadFactoryFn: payloadDecorator(odataPayloadFactory),
|
||||||
|
parentKeySelector: variables => variables.locator.descriptor.<%- parentKey %>,
|
||||||
});
|
});
|
||||||
|
|
||||||
const responseContract = createResponseContract({
|
const responseContract = createResponseContract({
|
||||||
|
|
|
@ -26,6 +26,10 @@ function composeSharedContext(metadata, scope, aliasHashMap) {
|
||||||
const odataUriSegments = odataCallUriFactory(visitedSchemas, rootSchema, aliasHashMap, isColl);
|
const odataUriSegments = odataCallUriFactory(visitedSchemas, rootSchema, aliasHashMap, isColl);
|
||||||
const descriptorList = generateDescriptorList(visitedSchemas, aliasHashMap, isColl);
|
const descriptorList = generateDescriptorList(visitedSchemas, aliasHashMap, isColl);
|
||||||
|
|
||||||
|
// note that for action/function, the "parent" is the _last_
|
||||||
|
// element of the descriptor list
|
||||||
|
const parentKey = descriptorList[descriptorList.length - 1];
|
||||||
|
|
||||||
const { ReturnType } = rootSchema.schema;
|
const { ReturnType } = rootSchema.schema;
|
||||||
let responseType = 'responseTypes.ENTITY';
|
let responseType = 'responseTypes.ENTITY';
|
||||||
let key = 'r => r';
|
let key = 'r => r';
|
||||||
|
@ -62,6 +66,7 @@ function composeSharedContext(metadata, scope, aliasHashMap) {
|
||||||
key,
|
key,
|
||||||
responseType,
|
responseType,
|
||||||
processor,
|
processor,
|
||||||
|
parentKey,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,10 @@ function composeSharedContext(metadata, scope, aliasHashMap) {
|
||||||
const descriptorList = generateDescriptorList(visitedSchemas, aliasHashMap, true);
|
const descriptorList = generateDescriptorList(visitedSchemas, aliasHashMap, true);
|
||||||
const { $$ODataExtension } = rootSchema.schema;
|
const { $$ODataExtension } = rootSchema.schema;
|
||||||
|
|
||||||
|
const parentKey = descriptorList.length > 1
|
||||||
|
? descriptorList[descriptorList.length - 2]
|
||||||
|
: descriptorList[0];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
edmLocation,
|
edmLocation,
|
||||||
envLocation,
|
envLocation,
|
||||||
|
@ -30,6 +34,7 @@ function composeSharedContext(metadata, scope, aliasHashMap) {
|
||||||
descriptorList,
|
descriptorList,
|
||||||
odataUriSegments,
|
odataUriSegments,
|
||||||
key: $$ODataExtension.Key[0],
|
key: $$ODataExtension.Key[0],
|
||||||
|
parentKey,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,10 @@ function composeSharedContext(metadata, scope, aliasHashMap) {
|
||||||
const descriptorList = generateDescriptorList(visitedSchemas, aliasHashMap, false);
|
const descriptorList = generateDescriptorList(visitedSchemas, aliasHashMap, false);
|
||||||
const { $$ODataExtension } = rootSchema.schema;
|
const { $$ODataExtension } = rootSchema.schema;
|
||||||
|
|
||||||
|
const parentKey = descriptorList.length > 1
|
||||||
|
? descriptorList[descriptorList.length - 2]
|
||||||
|
: descriptorList[0];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
edmLocation,
|
edmLocation,
|
||||||
envLocation,
|
envLocation,
|
||||||
|
@ -30,6 +34,7 @@ function composeSharedContext(metadata, scope, aliasHashMap) {
|
||||||
descriptorList,
|
descriptorList,
|
||||||
odataUriSegments,
|
odataUriSegments,
|
||||||
key: $$ODataExtension.Key[0],
|
key: $$ODataExtension.Key[0],
|
||||||
|
parentKey,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче