graphiti icon indicating copy to clipboard operation
graphiti copied to clipboard

Pagination links include all attributes on create

Open CathyRye opened this issue 4 years ago • 2 comments

Since updating to the latest graphiti version, we've found that pagination links generated after a POST include all attributes posted in the request. Since some of our models include image data, this results in absurdly long links.

The difference appears to be down to changes in this commit: https://github.com/graphiti-api/graphiti/commit/0e560ca4d7d43827c0bc4f648e4789bfaf491dd7 - specifically the switch from using @proxy.query.hash to @proxy.query.params to ensure filtering and include parameters are reflected in pagination links. This works, but has the side-effect of also including attributes from the post call.

So whereas previously we'd see generated links similar to:

"links":{
        "first":"http://localhost:3000/api/layers?page%5Bnumber%5D=1\\u0026page%5Bsize%5D=20",
        "last":"http://localhost:3000/api/layers?page%5Bnumber%5D=1\\u0026page%5Bsize%5D=20"
      }

We're now seeing links like the following, which are becoming unwieldly.

"links": {
        "self": "http://localhost:3000/api/layers?data%5Battributes%5D%5Bcategory%5D=other&data%5Battributes%5D%5Bimage_encoded%5D=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAAAEAAAAjCAYAAABVcWC0AAAAF0lEQVQImWNgoDI4cODAfyYGBgYGmhAAM1EDZDMMzagAAAAASUVORK5CYII%3D&data%5Battributes%5D%5Blegend_data%5D%5B%5D%5Barea_scalar%5D=98.94009437236348&data%5Battributes%5D%5Blegend_data%5D%5B%5D%5Barea_units%5D=ha&data%5Battributes%5D%5Blegend_data%5D%5B%5D%5Bcolor%5D=%23445E9E&data%5Battributes%5D%5Blegend_data%5D%5B%5D%5Blabel%5D=new&data%5Battributes%5D%5Bname%5D=Anomalies&data%5Battributes%5D%5Bnortheast_lat%5D=-31.029559&data%5Battributes%5D%5Bnortheast_lng%5D=150.3918825&data%5Battributes%5D%5Bsourced_at%5D=2021-05-05T22%3A50%3A52.76176646Z&data%5Battributes%5D%5Bsouthwest_lat%5D=-31.0216804&data%5Battributes%5D%5Bsouthwest_lng%5D=150.4103215&data%5Brelationships%5D%5Bgrower%5D%5Bdata%5D%5Bid%5D=85282&data%5Brelationships%5D%5Bgrower%5D%5Bdata%5D%5Btype%5D=grower&data%5Btype%5D=prescription&page%5Bnumber%5D=1&page%5Bsize%5D=20",
        "first": "http://localhost:3000/api/layers?data%5Battributes%5D%5Bcategory%5D=other&data%5Battributes%5D%5Bimage_encoded%5D=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAAAEAAAAjCAYAAABVcWC0AAAAF0lEQVQImWNgoDI4cODAfyYGBgYGmhAAM1EDZDMMzagAAAAASUVORK5CYII%3D&data%5Battributes%5D%5Blegend_data%5D%5B%5D%5Barea_scalar%5D=98.94009437236348&data%5Battributes%5D%5Blegend_data%5D%5B%5D%5Barea_units%5D=ha&data%5Battributes%5D%5Blegend_data%5D%5B%5D%5Bcolor%5D=%23445E9E&data%5Battributes%5D%5Blegend_data%5D%5B%5D%5Blabel%5D=new&data%5Battributes%5D%5Bname%5D=Anomalies&data%5Battributes%5D%5Bnortheast_lat%5D=-31.029559&data%5Battributes%5D%5Bnortheast_lng%5D=150.3918825&data%5Battributes%5D%5Bsourced_at%5D=2021-05-05T22%3A50%3A52.76176646Z&data%5Battributes%5D%5Bsouthwest_lat%5D=-31.0216804&data%5Battributes%5D%5Bsouthwest_lng%5D=150.4103215&data%5Brelationships%5D%5Bgrower%5D%5Bdata%5D%5Bid%5D=85282&data%5Brelationships%5D%5Bgrower%5D%5Bdata%5D%5Btype%5D=grower&data%5Btype%5D=prescription&page%5Bnumber%5D=1&page%5Bsize%5D=20",
        "last": "http://localhost:3000/api/layers?data%5Battributes%5D%5Bcategory%5D=other&data%5Battributes%5D%5Bimage_encoded%5D=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAAAEAAAAjCAYAAABVcWC0AAAAF0lEQVQImWNgoDI4cODAfyYGBgYGmhAAM1EDZDMMzagAAAAASUVORK5CYII%3D&data%5Battributes%5D%5Blegend_data%5D%5B%5D%5Barea_scalar%5D=98.94009437236348&data%5Battributes%5D%5Blegend_data%5D%5B%5D%5Barea_units%5D=ha&data%5Battributes%5D%5Blegend_data%5D%5B%5D%5Bcolor%5D=%23445E9E&data%5Battributes%5D%5Blegend_data%5D%5B%5D%5Blabel%5D=new&data%5Battributes%5D%5Bname%5D=Anomalies&data%5Battributes%5D%5Bnortheast_lat%5D=-31.029559&data%5Battributes%5D%5Bnortheast_lng%5D=150.3918825&data%5Battributes%5D%5Bsourced_at%5D=2021-05-05T22%3A50%3A52.76176646Z&data%5Battributes%5D%5Bsouthwest_lat%5D=-31.0216804&data%5Battributes%5D%5Bsouthwest_lng%5D=150.4103215&data%5Brelationships%5D%5Bgrower%5D%5Bdata%5D%5Bid%5D=85282&data%5Brelationships%5D%5Bgrower%5D%5Bdata%5D%5Btype%5D=grower&data%5Btype%5D=prescription&page%5Bnumber%5D=15&page%5Bsize%5D=20",
        "next": "http://localhost:3000/api/layers?data%5Battributes%5D%5Bcategory%5D=other&data%5Battributes%5D%5Bimage_encoded%5D=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAAAEAAAAjCAYAAABVcWC0AAAAF0lEQVQImWNgoDI4cODAfyYGBgYGmhAAM1EDZDMMzagAAAAASUVORK5CYII%3D&data%5Battributes%5D%5Blegend_data%5D%5B%5D%5Barea_scalar%5D=98.94009437236348&data%5Battributes%5D%5Blegend_data%5D%5B%5D%5Barea_units%5D=ha&data%5Battributes%5D%5Blegend_data%5D%5B%5D%5Bcolor%5D=%23445E9E&data%5Battributes%5D%5Blegend_data%5D%5B%5D%5Blabel%5D=new&data%5Battributes%5D%5Bname%5D=Anomalies&data%5Battributes%5D%5Bnortheast_lat%5D=-31.029559&data%5Battributes%5D%5Bnortheast_lng%5D=150.3918825&data%5Battributes%5D%5Bsourced_at%5D=2021-05-05T22%3A50%3A52.76176646Z&data%5Battributes%5D%5Bsouthwest_lat%5D=-31.0216804&data%5Battributes%5D%5Bsouthwest_lng%5D=150.4103215&data%5Brelationships%5D%5Bgrower%5D%5Bdata%5D%5Bid%5D=85282&data%5Brelationships%5D%5Bgrower%5D%5Bdata%5D%5Btype%5D=grower&data%5Btype%5D=prescription&page%5Bnumber%5D=2&page%5Bsize%5D=20"
    },

Whether pagination links ought to be being generated at all on a POST may be questionable, but in any case, it's hard to imagine this is the expected behaviour for link generation.

CathyRye avatar Jul 05 '21 07:07 CathyRye

+1

stwr667 avatar Jul 06 '21 05:07 stwr667

This can make the size of the JSON response 3-4 times larger than it needs to be, depending on the size of the original POST request being made. It seems to me the default behaviour shouldn't include the POSTed data in the pagination links. It would make POST-heavy applications unnecessarily inefficient.

stwr667 avatar Jul 06 '21 08:07 stwr667