Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter parameters _and and _or are not considered valid by auth checks when an operation is authenticated #1518

Open
eddiesholl opened this issue Jan 14, 2025 · 0 comments

Comments

@eddiesholl
Copy link
Contributor

eddiesholl commented Jan 14, 2025

Describe the bug
If a query is authenticated, it is not possible to provide a filter using _and or _or. It fails with an error like:

`Could not determine field metadata for filter key: '_and on AccordionItem entity'","stack":"Error: Could not determine field metadata for filter key: '_and on AccordionItem entity'\n at recurseThroughArg (.../@exogee/graphweaver-auth/lib/decorators/hooks/acl.js:169:15)

The auth module is trying to traverse the filter, but doesn't know what to do with _and and _or operations.

This is where the metadata is being processed, I think this piece is fine

public fieldMetadataForFilterKey(

To Reproduce
Steps to reproduce the behavior:

  1. Set up an entity with ACLs
  2. Create a query that supplies a filter, and it uses _and or _or
  3. Execute the query
  4. See the error that occurs at runtime

An example query is

	query accordionItems($location: AccordionLocation!, $council: String) {
		accordionItems(
			filter: {
				_and: [{ location: $location }, { _or: [{ council: $council }, { council_null: true }] }]
			}
			pagination: { orderBy: { itemOrder: ASC } }
		) {
			id
			location
			title
			content
			itemOrder
			isExpanded
		}
	}

Expected behavior
The query should be allowed to proceed by auth

Actual behavior
What actually happened.

Screenshots or Screencasts
If applicable, add screenshots or screencasts to help explain the issue.

Desktop (please complete the following information):

  • OS and version: [e.g. MacOS 13.3.1, Windows 11 v22H2]

Additional context
Add any other context about the problem here.

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

No branches or pull requests

1 participant