Request Header Fields Too Large for graphql queries

Hello,
I am sending a query from Appfarm to its graphql data, but the problem is that some times the query that I am sending through the query parameters is too big, and it returns the error 431 (Request Header Fields Too Large).

Is there a way that I could query using POST and put the query in the body?

Thank you!

1 Like

Yes,

According to the GraphQL spec, a GraphQL server should support both GET and POST requests, which Appfarm does.
A POST request is usually prefferable, since you won’t reach any URI Length Limits.

In my screenshots I have setup a POST request to my solutions GraphQL endpoint.

Here is the POST request:

return {
  "query": "{ b64File(filter: {af_createdDate: {gt: \"2024-01-01T22:00:00.000Z\"}}, limit: 100, skip: 10, sort: {af_createdDate: DESC}) { _id af_createdDate af_createdBy af_updatedDate af_updatedBy af_randomId af_sequentialId originalFileName mimeType fileSize fileContentLink file uploadProgress isPublic uploadComplete } }"
}

I have found that ChatGPT is pretty good at converting GET Queries to POST Queries :robot:

The response is as follows:

{
	"requestConfig": {
		"url": "https://skallevold-enterprises-dev.appfarm.app/api/graphql/",
		"headers": {
			"Authorization": "Bearer ",
			"x-af-sol-token-v1": "",
			"Content-Type": "application/json; charset=utf-8",
			"User-Agent": "Appfarm/106-0-37 skallevold-enterprises/development (client-service/web-request)"
		},
		"data": {
			"query": "{ b64File(filter: {af_createdDate: {gt: \"2024-01-01T22:00:00.000Z\"}}, limit: 100, skip: 10, sort: {af_createdDate: DESC}) { _id af_createdDate af_createdBy af_updatedDate af_updatedBy af_randomId af_sequentialId originalFileName mimeType fileSize fileContentLink file uploadProgress isPublic uploadComplete } }"
		}
	},
	"responseData": {
		"status": 200,
		"statusText": "OK",
		"rawData": {
			"data": {
				"b64File": [
					{
						"_id": "66425a86b35405d549a9b7d0",
						"af_createdDate": "2024-05-13T18:23:02.393Z",
						"af_createdBy": "650d946c14c6c39c99b8d95c",
						"af_updatedDate": null,
						"af_updatedBy": null,
						"af_randomId": "rPPFdQCnvM3aHIHhD8Pu2",
						"af_sequentialId": 527,
						"originalFileName": "Billing Drawer.png",
						"mimeType": "image/png",
						"fileSize": 198283,
						"fileContentLink": "",
						"file": null,
						"uploadProgress": null,
						"isPublic": null,
						"uploadComplete": true
					},

Hope that helps!

// Erik