Closed anodynos closed 6 years ago
You mention this will break the contract and, most likely, will break all the GraphQL tooling you use but I don't really understand why - could you elaborate?
If you apply @_
directive on a server-side it will break all the tooling that depend on a shape of response.
For example, caching clients like Apollo or Relay.
Also, it will break client-side code generation e.g. https://github.com/apollographql/apollo-cli#apollo-codegengenerate-output
I'm no so experienced with graphql & apollo especially, so I'm not sure if I get it right.
What I did is to have two middlewares, applied first and last on the request on my express (NestJS actually). It goes like this:
transform
and strips out all @_
directives.I know this is not terribly performant, but for my pet project I don't care at all.
If all other middlewares execute in the middle, I guess they can still operate, cause lodash works at the start and end of the queue, almost as if it was running on the client. Isnt that right?
@anodynos For server-side middleware yes. But if you try to do something complex on client-side it would fail.
I don't understand - why will it fail on the client side?
@anodynos If you using fetch or any simple client it will work as expected. But if you are doing complex transformations on client-side that depend on the shape of the response it will fail.
Thanks for this library, it's really cool!
You mention this will break the contract and, most likely, will break all the GraphQL tooling you use but I don't really understand why - could you elaborate?
I've experimented a bit in a pet project and I have had no problems with it so far :-)
Regards