Closed tendant closed 7 years ago
So, I played around with some ideas regarding validation and execution and I came to the conclusion that the format being fed into the executor should be different from the one passed to the validator; for two reasons, that is:
Otherwise, the executor is surely pluggable but you still need to implement fragment and variable resolution in each variant. (Plus, stuff like line numbers may have fulfilled its duty already during validation and could be stripped.)
I thus propose a further step between validation and executor, converting the "Validated Map" to a format more suited for execution. Opinions?
You are right. The transformed map should have different format from validated map.
The differences come from a few places:
There is a pending pull request (https://github.com/tendant/graphql-clj/pull/40) created by @aew, he introduced the validator using clojure.spec. We are on track to have this soon.
Ideally, the flow for graphql engine could be:
Query/Schema String -- Parser --> Parsed AST -- Transformation --> Transformed Map -- Validator --> Validation Error or Validated Map -- Executor --> Executor Error or Result
"Transformed Map" will be used by Validator and Executor for further processing. And also it will make validation and execution pluggable.