dot-http
dot-http copied to clipboard
Better experience for GraphQL requests
Attempting to create requests for a GraphQL server leads to some nasty syntax: https://github.com/bayne/dot-http/issues/9#issuecomment-586509962
Current plan for a response body generator:
POST {{base_url}}/graphql
< {%
var query = '{\
leftComparison: hero(episode: EMPIRE) {\
...comparisonFields\
}\
rightComparison: hero(episode: JEDI) {\
...comparisonFields\
}\
}\
fragment comparisonFields on Character {\
name\
appearsIn\
friends {\
name\
}\
}';
return {
"query": query
};
%}
> {% console.log(response); %}
Note the symmetry of the syntax:
-
< {% ... %}for a request body generator -
> {% ... %}for a response handler (existing)