sgqlc
sgqlc copied to clipboard
Support @directive(arg: value)
Support directives, such as:
query aQuery($ignoreX: Boolean) {
x @skip(if: $ignoreX)
}
What needs to be done here? I could help
We do not handle the directives at all and I never stopped to think about what to do about them.
For instance, on the schema
, we have projects like https://github.com/profusion/apollo-validation-directives/ where we could call local wrappers, like converting/validating types locally before sending the query or receiving the values (similar to the custom scalars).
On the operation
(executable), we could mark statements with directives, such as @skip()
above. Then let the server know how to process that information.
But how to integrate it's the cumbersome bit, maybe follow the .__fields__()
and provide a .__directives__()
and let the user specify name + args?
I think directives are very important. They are used a lot in most schema-first databases like nexus, dgraph, etc..
I'll definitely look how to integrate them (because I need them) but this might not happen before may this year. If you have any more concrete ideas until then, I'm happy to hear about them!
yes, we use a lot in our schema-first servers (that's why we created that apollo-validation-directives repo). But for clients, it's less frequently used, that's why I never bothered.
In the schema I'd use something like the __directives__()
as I said, can create a Directive()
that can be inherited, provide the name and arguments using what exists. And when interpreting the results, in addition to the scalar conversion we'd give it to the directive, allowing to do extra validations.
But to do operations, need to see if we could do some __directives__()
as well.
Hi @barbieri, any updates on supporting @directives for sgqlc?
We've got queries that use @include and support for this would be very helpful!
@aychang95 unfortunately out of time to implement it. Any help is appreciated :-)
In the operations generator, you'd have to search for the fragment casting (__as__
) or aliasing (__alias__
) and follow that path.
hey @barbieri , any progress (or plans) on this?