fix graphql query
This commit is contained in:
parent
5375feda51
commit
7849c5456b
1 changed files with 17 additions and 2 deletions
19
src/main.zig
19
src/main.zig
|
|
@ -132,9 +132,13 @@ fn getDevices(allocator: std.mem.Allocator, id_token: []const u8, username: []co
|
|||
\\}
|
||||
;
|
||||
|
||||
// Remove newlines for JSON payload
|
||||
const query_clean = try std.mem.replaceOwned(u8, allocator, query, "\n", " ");
|
||||
defer allocator.free(query_clean);
|
||||
|
||||
const body = try std.fmt.allocPrint(allocator,
|
||||
\\{{"query":"{s}","variables":{{"email":"{s}"}}}}
|
||||
, .{ query, username });
|
||||
, .{ query_clean, username });
|
||||
defer allocator.free(body);
|
||||
|
||||
const uri = try std.Uri.parse(appsync_url);
|
||||
|
|
@ -209,9 +213,20 @@ fn getRecirculationStatus(allocator: std.mem.Allocator, id_token: []const u8, se
|
|||
\\}
|
||||
;
|
||||
|
||||
var query_clean_buf: [query.len]u8 = undefined;
|
||||
// Remove newlines for JSON payload
|
||||
const query_replacements = std.mem.replace(
|
||||
u8,
|
||||
query,
|
||||
"\n",
|
||||
" ",
|
||||
query_clean_buf[0..],
|
||||
);
|
||||
const query_clean = query_clean_buf[0 .. query.len - ("\n".len * query_replacements)];
|
||||
|
||||
const body = try std.fmt.allocPrint(allocator,
|
||||
\\{{"query":"{s}","variables":{{"heater_serial_number":"{s}"}}}}
|
||||
, .{ query, serial_number });
|
||||
, .{ query_clean, serial_number });
|
||||
defer allocator.free(body);
|
||||
|
||||
const uri = try std.Uri.parse(appsync_url);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue