stepci / garph

Fullstack GraphQL Framework for TypeScript
https://garph.dev
MIT License
1.31k stars 17 forks source link

Directives #40

Open mishushakov opened 1 year ago

mishushakov commented 1 year ago

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' })
danstarns commented 1 year ago

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

mishushakov commented 1 year ago

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

mishushakov commented 1 year ago

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?

redbar0n commented 1 year ago

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

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

mishushakov commented 1 year ago

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