Skip to content

Feature: ability to attach custom attributes to field definitions. #1671

Open

Description

@Warxcell

Hey, I'm writing custom Executor, optimized for my needs (basically I need per coordinate cache) - so my idea is to attach custom cache resolver which will be called prior original one to check from cache. The issue is that it's very hard to do that - because I need to fork basically whole lib - it would be awesome if it's possible to attach custom attributes to field definition so I can check them later in my custom Executor.

Or even better - if we can incorporate that cache into ReferenceExecutor ?

What do you think?

Activity

  1. spawnia commented on Feb 17, 2025

    @spawnia
    Collaborator

    it would be awesome if it's possible to attach custom attributes to field definition

    You can, the array $config passed in \GraphQL\Type\Definition\FieldDefinition::__construct is stored in a public property unchanged.

    I don't really understand what else you are describing.

  2. Warxcell commented on Feb 17, 2025

    @Warxcell
    ContributorAuthor

    Its fine, but there are 2 issues

    1. That array is not transferred during SchemaExtend - everything else besided known props for the graphql are lost.
    2. The config itself is strongly typed with specific keys - so phpstan will complain that custom indexes doesn't exists.
  3. spawnia commented on Feb 17, 2025

    @spawnia
    Collaborator

    Perhaps you can propose a pull request to fix 1.? And in regards to 2., strong typing won't be possible either way - you can ignore PHPStan errors though.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions