I want to modify the response of hasura fetch query.
the current response is this:
{
"data": {
"ids": [
{
"id_object": {
"id": 33102
}
},
{
"id_object": {
"id": 33104
}
}
]
}
}
And I want to remove "id_object" and want just array of id's like this:
{
"data": {
"ids": [
{
"id": 33102
},
{
"id": 33104
}
]
}
}
A GraphQL server exposes an exact set of operations and the shape of the allowed responses for those operations. When interacting with any GraphQL server (Hasura or otherwise), it is therefore not possible to to arbitrarily modify the shape of the returned data.
You're free to map it into a new form when you receive the data on the client side.
If you really need the server itself to be able to respond using this shape, you'll need to extend Hasura's schema to be able to specifically support this query pattern.
There are a number of different ways that you could accomplish this:
You could write a custom Hasura Action
You could expose this query from your own GraphQL server and then stitch it together with Hasura using Remote Schemas
You could use a Postgres View or Function to shape the data as required and expose it as a new operation
Related
I'm trying to use Power Automate to return a custom work item in Azure DevOps using the "workitemsearch" API (via the "Send HTTP Request" action). Part of this will require me to filter based on the value of a Custom Field, however, I have not been able to get it to work. Here is a copy of my HTTP Request Body:
{
"searchText": "ValueToSearch",
"$skip": 0,
"$top": 1,
"filters": {
"System.TeamProject": ["MyProject"],
"System.AreaPath": ["MyAreaPath"],
"System.WorkItemType": ["MyCustomWorkItem"],
"Custom.RequestNumber": ["ValueToSearch"]
},
"$orderBy": [
{
"field": "system.id",
"sortOrder": "ASC"
}
],
"includeFacets": true
}
I have been able to get it to work by removing the Custom.RequestNumber": ["ValueToSearch"] but am hesitant to use that in case my ValueToSearch is found in other places like the comments of other work items.
Any help on this would be appreciated.
Cheers!
From WorkItemSearchResponse, we can see the facets (A dictionary storing an array of Filter object against each facet) only supports the following fields:
"System.TeamProject"
"System.WorkItemType"
"System.State":
"System.AssignedTo"
If you want to filter RequestNumber, you can just set it in the searchText as the following syntax:
"searchText": "RequestNumber:ValueToSearch"
I'm working on an app, which is supposed to show data from two nodes(Firebase). Firebase DB is structured as:
{
"College": {
"4F2EAB65": {
"id": "4F2EAB65",
"name": "SomeCollege"
},
"A3C2ED31": {
"id": "A3C2ED31",
"name": "OtherCollege"
},
"F967B5A0": {
"id": "F967B5A0",
"name": "CoolCollege"
}
},
"Student": {
"3E20545B": {
"college-ID": "4F2EAB65",
"id": "3E20545B",
"name": "A"
},
"6FDEE194": {
"college-ID": "F967B5A0",
"id": "6FDEE194",
"name": "B"
}
}
I want to fetch student details having details: "id", "name", "college-ID", "college-Name"(Need to fetch "college-Name" by "college-ID").
I've achieved this using for loop at front end. Is there any way to get this achieved at Firebase server, also can we make something like join (SQL).
Thanks.
There is no support for server-side joins in the Firebase Realtime Database. Client-side joins are quite normal.
The alternative is to duplicate the data upon writing, so that you don't have to read from two locations.
What's best for your application is a matter of personal preference, your comfort level with the code involved vs data duplication, and the use-cases of your app.
Client-side jons are likely not as slow as you may think. See http://stackoverflow.com/questions/35931526/speed-up-fetching-posts-for-my-social-network-app-by-using-query-instead-of-obse/35932786#35932786
I'm trying to add a custom analyzer to elasticsearch via grails plugin. I was able to change the used analyzer to a common analyzer using "searchable" on the domain:
static searchable = {
all = [analyzer: 'snowball']
}
but cannot get it to know a costum analyzer. It is unclear how to translate the following json in the REST API to a groovy closue:
PUT /my_index
{
"settings": {
"analysis": {
"filter": {
"my_synonym_filter": {
"type": "synonym",
"synonyms": [
"british,english",
"queen,monarch"
]
}
},
"analyzer": {
"my_synonyms": {
"tokenizer": "standard",
"filter": [
"lowercase",
"my_synonym_filter"
]
}
}
}
}
}
this question seems to have the same problem but the answer doesn't work, and this answer suggests that it might not be possible, but that doesn't seem reasonable because setting a custom analyzer is pretty basic.
Any suggestions?
There are two ways I see which would help you achieve that.
The first way is by going through the low level API using the injected elasticSearchHelper and accessing ES client directly.
elasticSearchHelper.withElasticSearch { client ->
// Do some stuff with the ElasticSearch client
client.admin()
.indices()
.prepareCreate(indexName)
.setSettings(settings) <--- your settings/analyzers go here
.execute()
.actionGet()
}
A second way involves using an undocumented feature of the ElasticSearchAdminService service, namely the createIndex() method, which allows you to pass in the settings and analyzers you need when creating a new index. The latter basically does exactly the same as the first option above, but you get to use the Grails service directly.
My oData query is as follow.
http://localhost:21005/api/v1/Devices?$expand=Jobs
My oData JSON response (in Postman's Pretty format) is as follow.
{
"#odata.context": "http://localhost:21005/api/v1/$metadata#Devices",
_"value": [
{
"Id": "abc03c74-8697-49ec-85e6-6444112d0336",
"TimeOffset": 0,
"TimeOffsetMode": "Unmanaged",
"Jobs": [
{
"#odata.type": "#VT.Api.Models.GetDataJob",
"Id": "ba07d50a-f17d-4c65-b3cf-f3e03d1ba1cf"
},
{
"#odata.type": "#VT.Api.Models.GetDataProfilerJob",
"Id": "5aa9c046-e4f2-44de-b932-16c06b86b084"
},
{
"#odata.type": "#VT.Api.Models.GetDeviceConfigurationJob",
"Id": "d7dc0ac5-1f89-4356-aaa8-9ac40353e1af"
}
}
{
"Id": "d42ac1f0-1261-4100-8391-013a226ff25f",
"TimeOffset": 0,
"TimeOffsetMode": "Unmanaged",
"Jobs": [ ]
}
}
Now, I want to query for only specific "#oData.type"
For example, I just want all the "Jobs" whose data type is "#VT.Api.Models.GetDataJob" ("#odata.type": "#VT.Api.Models.GetDataJob"). What kind of filter or query should I use?
The query should be:
http://localhost:21005/api/v1/Devices?$expand=Jobs($filter=isof('VT.Api.Models.GetDataJob'))
but as Brad said, IsOf has not been implemented in webapi odata v4.
According to the current spec, the correct way would be to apply a type filter to the expand expression, e.g.:
http://host/service/Orders?$expand=Customer/Model.VipCustomer
or, using your example,
http://localhost:21005/api/v1/Devices?$expand=Jobs/VT.Api.Models.GetDataJob
Please note that this will return all devices, expand their Jobs association, and only add GetDataJob instances to the resulting association sets. If you only want to query devices that have GetDataJob instances, you will need to see if you can use lambdas with type filters.
See also this SO question and OData Version 4.0 Part 2: URL Conventions
According to the OData spec you should be able to use the "IsOf" function to accomplish this. However, I don't believe this has been implemented yet in WebApi OData v4 (assuming that's what you're using):
https://github.com/OData/WebApi/issues/185
I want to use RestKit to consume a web service.
My collections end point returns something like this.
{
"meta": {
"limit": 20,
"next": "...",
"offset": 0,
"previous": null,
"total_count": 23
},
"objects": [
"..."
],
"requested_time": 1396875600.810225
}
The key "objects" can return an array of one of many types of elements. But always the same for a given collection.
How can I map this response with the ObjectManager?
The complete your object manager configuration you create a number of response descriptors. These descriptors match against path patterns of the response URL and include the mapping to be used to process the response content.
In this way you will have a different response descriptor for each path pattern which returns different content and the linked mapping will instruct RestKit on what type of object to create and how top populate it.