# Make sure we're at the edge POP
# Check that the client request is a POST
if (fastly.ff.visits_this_service == 0 && req.method == "POST") {
# Check there is a body present
if (req.body) {
# Convert the request method to GET
set req.method = "GET";
# Reformat the JSON payload
call json_payload_clean;
# Serialize body parameters as querystring
set req.url = "/v1/graphql?query=" + req.http.formatted-body;
# Unset CT, as its only needed for POST
unset req.http.Content-Type;
# Unset formatted-body header, as its only needed to build URL path
unset req.http.formatted-body;
} else {
# If no body is present, then that means either
# the client never sent it, or it exceeded 8KiB in size.
# In this case we cannot convert the request so we may either
# PASS directly to origin as is, or error out.
return(pass);
}
}