Reduce data returned from API

Hello everyone,

I'm querying prismic's REST API, and I'm wondering whether it's possible to trim down the amount of data that comes back from it.

I'm trying to query just a list of names from a collection, but the API returns a ton of unnecessary meta data:

1. license: "All Rights Reserved"
2. next_page: some-url
3. page: 0
4. prev_page: null
5. results: (11) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
6. results_per_page: 20
7. results_size: 11
8. total_pages: 1
9. total_results_size: 11
10. version: "ec04165"

And each result has this shape:

1. alternate_languages: []
2. data: {name: "The data I want"}
3. first_publication_date: "2021-01-22T12:50:41+0000"
4. href: some-url
5. id: "asdf"
6. lang: "en"
7. last_publication_date: "2021-01-22T12:50:41+0000"
8. linked_documents: []
9. slugs: ["theslug"]
10. tags: []
11. type: "page"
12. uid: null

I wonder if there's a way to make this query faster by removing literally all of this data, except for "The data I want", which is buried deep in the API response? I'm restricting that data via the graphQuery search param, but I don't need any of the other data either.

Hey @florian,

This is a good question. There is no way to exclude metadata from your query. Even the query helpers like getSingle retrieve a full response from the API, and then manipulate the response to return just an individual document.

Having said that, this is an interesting use case, so I'll flag this with our product team as a potential feature. (If you want to add more detail, you could submit a feature request, here, which would allow others to weigh in as well.)

Sam

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.