When I use the `@include` (or @skip) directive, do...
# apollo-kotlin
s
When I use the
@include
(or @skip) directive, does the change happen on the client, meaning that I send different requests to the backend depending on what boolean value I pass in them, or does it go as-is to the backend and the backend is the one that is supposed to honor my request to include or skip those fields? And as a follow-up, if this does rely on my backend doing the right thing, how do I know if my backend will know how to work with this directive or not?
To add to this, it does seem to work now that I am testing this with our backend, but I just wanna make sure I understand why it works 😄
e
Looking at the generated code, it goes as-is to the backend, as the
OPERATION_DOCUMENT
returns a constant string. I assume the reason why this works is that this it's something that is part of the GraphQL specification (here), and the backend GQL stack you use implements this specification correctly. Depending on what you use there, you should be able to find exactly what part of the spec they implement or not.
thank you color 1
☝️ 1
s
Yeah I saw the OPERATION_DOCUMENT being sent as-is and I was really confused initially as I thought it was a client-side thing, but you are right, it certainly looks like it's just being forwarded to the backend this way. Yeah so my answer here would be "if it looks like it's working, then it's working" I suppose 😄 And this is not advertised by the backend in some explicit way, besides just the expectation that "they follow the spec" which should imply that they also support this directive. That's what I am getting out of this I think
m
Exactly what @Eduard Boloș said. This is 100% a backend thing.
It’s been there since the initial release of GraphQL and is there forever. All the servers have to support it.
s
Alright, I have just been living under a rock then, because I had never used it before and I assumed it's a new-ish thing 😅
😄 1