-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
Support custom directives #159
Comments
Keen to raise a PR? Ideally something like option 3, but you could also go with option 2 as a stepping stone. |
@tlil @BilyachenkoOY Hey guys, I implemented option 2 and did some investigation related to it as a first step to this enhancement - looking at graphql-dotnet Schema.cs, registering directives is treated the same way as registering types, so the WithDirective(DirectiveGraphType) should not call _schema.RegisterDirective/s directly as this can cause an InvalidOperationException if the the Schema is Initialized; Instead it should work like WithQuery for example, only remembering the provided types;
Or should it be somewhat like the Query / Mutations classes, having a wrapper class, which will be passed to a new method in GraphQLEngine - WithDirective. Then all first level nested classes will be handled as Directives
These are the two options that come to mind when I think about describing directives as classes - it is completely possible that I am missing something here. Can you give me an example of how exactly the end result should look like? |
@K-Pavlov Working with directives (like so much else) has been heavily changed in GraphQL.NET v4. See graphql-dotnet/graphql-dotnet#2276 and especially https://github.com/graphql-dotnet/graphql-dotnet/pull/2276/files#diff-8cc34927497a4d6a5aa8a4626fee297f7090758816221962d3a312d89bc522c7 |
@sungam3r Thanks for the heads-up! It would be better to wait for GraphQL.NET v4 before implementing this. Also it seems reasonable that adding support for server-side directives when fields are generated should be part of this enhancement (a field / property attribute seems reasonable); Excellent work on the directives and the much appreciated documentation 👍 |
It would be nice to add support of custom directives, since currently it is only available via reflection to get
_schema
fromGraphQLEngine
and invokeRegisterDirective
passingDirectiveGraphType
.There are few ways:
_schema
, so that any custom operation wich is possible in graphql-dotnet will be possible with graphql-dotnet conventionsBuildSchema
executedWithDirective(DirectiveGraphType)
method which will be just a proxy to_schema
BuildSchema
is called or register directory immediately to_schema
if it is already constructedThe text was updated successfully, but these errors were encountered: