Skip to content

Improve support of executable directives #355

@KaSSaaaa

Description

@KaSSaaaa

Hi,

I was trying to add a custom executable directive to my schema. This directive looks like this :

directive @timeFormat(format: String!) on FIELD | FIELD_DEFINITION

scalar DateTime

This would be applied on the DateTime scalar and would give the possibility to change the result to the expected format, let's say YYYY-MM-DD for example.

Currently, the only way I found to implement this behavior is, for each field where the return type is DateTime, to take the FieldParams in a custom Result where I would check all the directives available and apply the correct directives with the correct params. This is quite cumbersome in my opinion because if in the future I want to be able to do so on a Date, I would have to change all those fields as well...

I was wondering if there was another way to do that, in a more centralized way where, rather than doing it on the resolver level, it would be done on the schema level. Is there something like that ? Like a DirectiveHandler Registry or something ? If not, would that be foreseen in a future version ?
I'd be interrested in helping if needed.

Thanks in advance for your answer

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