garph icon indicating copy to clipboard operation
garph copied to clipboard

Directives

Open mishushakov opened this issue 2 years ago • 5 comments

Add support for specifying and implementing GraphQL directives in Garph

Example:

const d = g.directive('Name', { param: g.string() }, ['FIELD', 'ARGUMENT'])

g.type('Query', {
  test: g.string()
    .args({
      test: g.string().addDirective(d, { param: 'Hello' })
    })
    .addDirective(d, { param: 'Hello' })
})
.addDirective(d, { param: 'Hello' })

mishushakov avatar Mar 09 '23 15:03 mishushakov

+1 for Directives. Want to add isAuthenticated to my schema.

danstarns avatar Mar 09 '23 16:03 danstarns

Thanks, @danstarns. I will add some more details to the details

mishushakov avatar Mar 09 '23 17:03 mishushakov

Hey @danstarns, I've updated the issue. Could you take a look and tell me what you think?

I'm also curious about the use-case for directives. What are people are using them for? Are they used on client-side when making requests?

mishushakov avatar Mar 14 '23 11:03 mishushakov

Here is a relevant issue, with a lot of resources on how directives are used:

https://github.com/gqty-dev/gqty/issues/448

redbar0n avatar Apr 24 '23 15:04 redbar0n

@danstarns Would you rather use middleware/plugins instead of directives?

mishushakov avatar May 04 '23 13:05 mishushakov