Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
1801584810_2
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