API: content/{app}/{schema}/{api} seems have some bugs

I call an API example, the X-Flatten has an effect, but the X-Fields has no effect.

I also saw this source code; the fields are always set to null. (I am not sure whether it is the key point code.)

It only works on the root level. So something like “lastModified”, “data.fields” … it is leveraged in the frontend to only fetch the current fields for the table view. I have just verified that it works as expected.

Even if I use the minimum param, only id, it still doesn’t work.

Could you give an example?

I found this doc( Document Processors and Operation Processors · RicoSuter/NSwag Wiki) about it. Seems it is works after query db, that is not I want it, any operate have we can query specify fields when call the API, like GraphQL.

it is only meant for data fields, the purpose is basically for the UI. I have no plans to extend that as grapqhl-already solves it well.

Could you give an example? Thanks.

Just check the requests in your browser, when you go to the content view. then you can play around with the results

I put 'data.title′ to X-Fields, but this response return all data fields.

For me it works:

Without headers:

I think I never enabled it for the ID query because I didn’t need it for the UI

That’s awesome! Thank you mention me this, I removed the id param, it worked.

Seems it has some problem with id.

Yes, but as I said: It was never needed for this endpoint, so I have not added it. You can create a feature request, but it does not have the highest prio as I encourage everybody to use GraphQL anyway.

I wonder why the API with ID didn’t work.

They are two different API:

  • [Route(“content/{app}/{schema}/”)]
  • [Route(“content/{app}/{schema}/{id}/”)]

I found this reason in the API without the id, it has a feature([AcceptQuery(true)][AcceptHeader.NoSlowTotal], and [AcceptHeader.NoTotal]), and other API don’t have it.

The actual problem is that the API with id uses the FindAsync method, the others use the QueryAsync method, and the QueryAsync method calls a ParseCoreAsync method calls a ParseAsync method; the key point code is the WithFields method. But the FindAsync method does not call the WithFields method.

Ok, I think back, this was accepted, I just want reduce this data transport, because I have some field have large text, but this time I don’t want load it.

By the way, this query is a db level, not only NSWag

Yes, I know :wink: … I have written it :smiley:

Do you override the API([Route(“content/{app}/{schema}/{id}/”)])? I am viewing the source code of FindAsync, but I can’t understand it. This seems to read from the event message, and I have even used it.

What do you mean with override? The acutal code is here: squidex/backend/src/Squidex/Areas/Api/Controllers/Contents/ContentsController.cs at master · Squidex/squidex · GitHub

I saw this, the FindAsync method, finally execute WithEventSourcing, this is an event message, and I haven’t used it, how to execute query, and there seems no way to filter fields.

I means how to handler fields params.

You have to follow this path: squidex/backend/src/Squidex.Data.MongoDb/Domain/Apps/Entities/Contents/MongoContentRepository.cs at master · Squidex/squidex · GitHub