Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -352,34 +352,19 @@ export const getOwnerClaimReference = (ownerClaim: string, refName: string): str
return ownerRef;
};

/**
* Creates field resolver for owner
*/
/**
* Creates field resolver for owner
*/
export const generateFieldResolverForOwner = (entity: string): string => {
const expressions: Expression[] = [
ifElse(
methodCall(ref('util.isList'), ref(`ctx.source.${entity}`)),
compoundExpression([
set(ref('ownerEntitiesList'), list([])),
set(ref(entity), ref(`ctx.source.${entity}`)),
forEach(ref('entities'), ref(entity), [
set(ref('ownerEntities'), ref(`entities.split("${IDENTITY_CLAIM_DELIMITER}")`)),
set(ref('ownerEntitiesLastIdx'), raw('$ownerEntities.size() - 1')),
set(ref('ownerEntitiesLast'), ref('ownerEntities[$ownerEntitiesLastIdx]')),
qref(methodCall(ref('ownerEntitiesList.add'), ref('ownerEntitiesLast'))),
]),
qref(methodCall(ref(`ctx.source.${entity}.put`), ref('ownerEntitiesList'))),
toJson(ref('ownerEntitiesList')),
]),
compoundExpression([
set(ref('ownerEntities'), ref(`ctx.source.${entity}.split("${IDENTITY_CLAIM_DELIMITER}")`)),
set(ref('ownerEntitiesLastIdx'), raw('$ownerEntities.size() - 1')),
set(ref('ownerEntitiesLast'), ref('ownerEntities[$ownerEntitiesLastIdx]')),
qref(methodCall(ref('ctx.source.put'), str(entity), ref('ownerEntitiesLast'))),
toJson(ref(`ctx.source.${entity}`)),
]),
toJson(ref(`ctx.source.${entity}`)),
toJson(ref(`ctx.source.${entity}`)),
),
];

return printBlock('Parse owner field auth for Get')(compoundExpression(expressions));
};
Original file line number Diff line number Diff line change
Expand Up @@ -259,35 +259,20 @@ export const setDeniedFieldFlag = (operation: string, subscriptionsEnabled: bool
return '';
};

/**
* Creates field resolver for owner
*/
/**
* Creates field resolver for owner
*/
export const generateFieldResolverForOwner = (entity: string): string => {
const expressions: Expression[] = [
ifElse(
methodCall(ref('util.isList'), ref(`ctx.source.${entity}`)),
compoundExpression([
set(ref('ownerEntitiesList'), list([])),
set(ref(entity), ref(`ctx.source.${entity}`)),
forEach(ref('entities'), ref(entity), [
set(ref('ownerEntities'), ref(`entities.split("${IDENTITY_CLAIM_DELIMITER}")`)),
set(ref('ownerEntitiesLastIdx'), raw('$ownerEntities.size() - 1')),
set(ref('ownerEntitiesLast'), ref('ownerEntities[$ownerEntitiesLastIdx]')),
qref(methodCall(ref('ownerEntitiesList.add'), ref('ownerEntitiesLast'))),
]),
qref(methodCall(ref(`ctx.source.${entity}.put`), ref('ownerEntitiesList'))),
toJson(ref('ownerEntitiesList')),
]),
compoundExpression([
set(ref('ownerEntities'), ref(`ctx.source.${entity}.split("${IDENTITY_CLAIM_DELIMITER}")`)),
set(ref('ownerEntitiesLastIdx'), raw('$ownerEntities.size() - 1')),
set(ref('ownerEntitiesLast'), ref('ownerEntities[$ownerEntitiesLastIdx]')),
qref(methodCall(ref('ctx.source.put'), str(entity), ref('ownerEntitiesLast'))),
toJson(ref(`ctx.source.${entity}`)),
]),
toJson(ref(`ctx.source.${entity}`)),
toJson(ref(`ctx.source.${entity}`)),
),
];

return printBlock('Parse owner field auth for Get')(compoundExpression(expressions));
};

Expand Down