Skip to content

Conversation

@fraxachun
Copy link
Contributor

@fraxachun fraxachun commented Dec 11, 2025

Description

Use this decorator in following cases:

  • You don't have an entity to check with @AffectedEntity
  • You want to check for a combination of content scope values.

Example:

@Query(() => [Product])
@AffectedScope((args) => ({ country: args.country, department: args.department }))
async products(@Args("country", { type: () => string }) id: string, @Args("department", { type: () => string }): Promise<Product[]> {
    // Note: you can trust "country" and "department" being in a valid scope in the sense that the user must have a content scope which is a combination of these dimensions:
    // [{ country: "AT", department: "main" }]; // ok
    // [{ country: "AT" }, { department: "main" }]; // not sufficient
}

Further Information

"@comet/cms-api": minor
---

Skip undefined values in content scope check
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See 352cca4

Why this change?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't changing this a breaking change? Now null isn't treated as "not existing" any longer, but rather "no specific value set". I can imagine that this would break access control in some of our applications.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main difference is that it's a bit more loose.

Before:
{foo: undefined} forced the user having {foo: null} or {foo: undefined}
{foo: null} forced the user having {foo: null} or {foo: undefined}

Now:
{foo: undefined} doesn't require to have a content scope
{foo: null} forces the user having {foo: null}

It's breaking indeed if the user's content-scope consists of undefined values:
Breaking:
{foo: null} isn't allowed anymore if the user has {foo: undefined}
Can we neglect this? If not, re-adding these lines should be make it compatible again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also could revert this breaking change. It's not really necessary, but it makes handling optional values easier in argsToScope easier.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we neglect this? If not, re-adding these lines should be make it compatible again.

@Ben-Ho @kaufmo what do you think about this? To my best knowledge you're the only ones that have projects with optional scope dimensions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants