Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Planning for directive support #156

Closed
vektah opened this issue Jun 29, 2018 · 7 comments
Closed

Planning for directive support #156

vektah opened this issue Jun 29, 2018 · 7 comments

Comments

@vektah
Copy link
Collaborator

vektah commented Jun 29, 2018

Once the new parser lands and we get full support for directives. These things don't need to be in the core runtime, and should be implementable outside. This probably means codegen hooks.

Possible uses:

@resolver

A way to force creating a resolver method for a field, eg

type User {
    name @resolver
}

would generate a Name resolver even if the user struct has a Name field.

@rest, @grpc, @swagger

These would implement the resolver method for you by binding to an external API.

type Query {
    user(id: Int!): User @grpc(accounts:"foo.bar", method:"GetUsers")
}

@hasRole, @isAdmin, @isAuthenticated

These act as middleware filters, and should be able block calling the resolver

type Mutation {
    banUser(id: Int!): User @isAdmin
}

@resolveString and all of the graphql-cats directives

They shouldn't be part of the core, but a way to implement them to test against cats is really high on my list.

@skip and @include

these are both runtime directives, not schema but there is probably some overlap here and its worth thinking about them.

These are the ones I want. What do you want to see? Lets collect some ideas before rushing into an implementation.

@connection?

Is there some codegen hook that would make dealing with relay style connections easier?

@vektah vektah changed the title Planning for schema directive support Planning for directive support Jun 29, 2018
@vvakame
Copy link
Collaborator

vvakame commented Jul 3, 2018

My team really needs this feature ASAP 🤣
I want to use @isResourceOwner and @isStaff on QUERY | FIELD.
so, Is there anything I can do for you? 🌹

@sergeyvlakh
Copy link

@skip/@include 👍 👍 👍

@ntucker
Copy link

ntucker commented Jul 14, 2018

@Skip and @include are both key for using relay-modern effectively.

@vvakame
Copy link
Collaborator

vvakame commented Jul 15, 2018

#130 (comment)
vektah said

The new parser is nearly done now, full directive support should only be a few weeks away.

@mathewbyrne mathewbyrne self-assigned this Jul 18, 2018
@andy9775
Copy link

Would it be possible to write our own directives like in Apollo?

@mathewbyrne mathewbyrne removed their assignment Jul 19, 2018
@mathewbyrne
Copy link
Contributor

@andy9775 yes we are currently planning to make directives work much the same as resolvers currently do; directives found in a schema will be generated and you will be able to supply your own implementation.

@vektah
Copy link
Collaborator Author

vektah commented Jul 23, 2018

I've broken these out into smaller cards on the 1.0 board

@vektah vektah closed this as completed Jul 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants