Skip to content

Instantly share code, notes, and snippets.

Last active April 22, 2021 15:54
What would you like to do?
extension Query {
static func decodeResponse(_ data: Data) throws -> Response {
JSONDecoder().decode(Response.self, from: data)
// The query file on disk
var body: String {
// Assume it has the same name as the query type
try! String(contentsOfFile: Bundle.main.path(forResource: String("\(type(of: self))".split(separator: ".").last!), ofType: "query")!)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment