Skip to content

Declarative include/exclude support for arguments in cache keys #348

Description

@AlexanderGH

Feature request for normalized caching:
we have:

  foo(bar: $bar, baz: $baz, bob: $bob) {
    ...Stuff
  }

but we want to ignore "bob" for cache keys so we have a

override fun getFieldKey(context: FieldKeyContext): String {
        return if (context.parentType == MyType.type.name && context.field.name =="foo") {
            val newField = context.field.newBuilder()
                .arguments(
                    context.field.arguments.filter { argument ->
                        argument.definition.name != "bob"
                    },
                )
                .build()
            val newContext = FieldKeyContext(
                parentType = context.parentType,
                field = newField,
                variables = context.variables,
            )
            connectionFieldKeyGenerator.getFieldKey(newContext)
        } else {
            connectionFieldKeyGenerator.getFieldKey(context)
        }
    }

is there a way to support this in the normalized cache key config similar to (hypthetical syntax)

extend type MyType {
  entities @typePolicy(ignoreArguments: "bob")
}

or the inverse

extend type MyType {
  entities @typePolicy(keyArguments: "bar baz") // ignores bob
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions