How does the backend return several of the union types on demand - apollo-server

The front-end uses the union type to request on-demand, and how does the back-end fetch data from the database on demand?

Related

No Group By action when using REST Data Source in Interactive Report

We have tried consuming a (ORDS) REST service in an Oracle APEX (v.20.2) interactive report using two different methods:
Using REST Data Source, as defined in Shared Components
configured as Oracle REST Data Services
Using a Local Database source call in this format: select * from json_table( apex_web_service.make_rest_request( p_url => and so on. (using WITH_PLSQL hint)
Both ways work well, but the problem is when using the more clean method, 1, then the Actions menu contains less options, compared to method 2, for example the Group By is missing.
As ORDS returns its data in pages, APEX by default assumes that not all data is available when the Interactive Report renders (only the rows which are actually seen on the report page). Thus the report options, which need to access all data, are disabled.
To change that, do the following:
In Shared Components, navigate to your REST Data Source
Edit the "GET" (Fetch Rows) Operation
Enable the Allow Fetching All Rows switch.
For a normal report view, the behavior will not change; APEX will only fetch rows from ORDS, as needed to display the report page. But now, the Chart and Group By options will appear - and if you configure a GROUP BY, APEX will potentially execute multiple HTTP requests to get all required rows from your REST API.
So be careful with this for REST Services potentially returning a large amount of rows ...
Hope this helps

can I write custom sql with graphene-sqlalchemy?

Can we write custom sql with graphene-sqlalchemy to retrieve data? My output is not present in a database table directly but is built using 'CTEs'.
Background: I'm trying to build a graphql backend in python. The purpose is that this graphql backend layer will act as an API layer. And if I have to switch between different datasources, all I would do is change the connection string and everything else would remain same.
Summary:
My graphene models will have to be built off of database views and not database tables. I will only be querying the data and not performing any mutations.
I want my data resolvers need to run dynamic queries (based on inputs passed) on tables and then aggregate data and return results. Because of the this aggregations happening on the fly based on inputs I cannot pre-aggregate the data and store in tables. So I want to execute this dynamic sql against tables.
Table-Tasks has 3 columns: id name user_id
Table Issues has 4 columns: id task_id issue_status user_id
So I will build views A and B (lets say) on these tables based on the inputs I get and then do aggregations on these views. So an ability to write custom sql for my resolvers will help a lot. Is that possible in graphene-sqlalchemy?

Benefits of using Graphql in Magento 2

Can someone explain the benefits of using Graphql in your Magento/Magento 2 site?
Is it really faster than a normal query or using collections. Because from what i see is that you still have to set/fetch all data in the resolver that was declared on the schema.graphql so that it will be available on every request.
Is it faster because each set of data is cached by graphql or is their a logic behind it that make it faster?
Like when you just need a name, description of a product you would just have to call getCollection()->addAttributeToSelect(['name', 'description'])->addAttributeToFilter('entity_id', $id)->getFirstItem() inside your block wherein a graphql request the data will be fetch via the resolver which all the data of the product is being fetch.
Regarding about performance , GraphQL is normally faster than the equivalent REST API if the client needs to get a graph of data and assuming GraphQL API is implemented correctly . Otherwise ,it may easily lead to N+1 loading problem which will make the API slow.
It is faster mainly because client only need to send one request to get the whole graph of the data while in the REST API , client need to send many HTTP requests separately to get the whole graph of data. The number of network round trip is reduced to one in GraphQL case and hence it is faster (Of course, it assumes that there is no single equivalent REST API to get this graph of data. 😉)
In other words , if you only get a single record , you will not find there is much performance differences in the REST API and GraphQL API.
But besides performance , what GraphQL API offers is to allow user to get the exact fields and exact graph of data that they want which is difficult to be achieved in REST API.

Paging SELECT query results from Cassandra in Spring Boot application

During my research I have come across this JIRA for Spring-Data-Cassandra:
https://jira.spring.io/browse/DATACASS-56
Now, according to the post above, currently SDC is not supporting Pagination in the Spring App due to structure of Cassandra. However, I'm thinking, if I can pull the entire rows list into a Java List, can I Paginate that list ? I don't have much experience in Spring, but is there something I am missing when I assume this can be done ?
Cassandra does not support pagination in the sense of pointing to a specific page (limit/offset) but generates a continuation token (PagingState) that is a set of bytes. Pulling a List of records will load all records in memory and possibly exhaust your memory (depending on the amount of data).
Spring Data Cassandra 1.5.0 RC1 comes with a streaming API in CassandraTemplate:
Iterator<Person> it = template.stream("SELECT * FROM person WHERE … ;", Person.class);
while(it.hasNext()) {
// …
}
CassandraTemplate.stream(…) will return an Iterator that operates on an underlying ResultSet. The DataStax driver uses a configurable fetch-size (5000 rows by default) for bulk fetching. Streaming data access can fetch as much or as little data as you require to process data. Data is not retained by the driver nor Spring Data Cassandra, and once the fetched bulk is retrieved from the Iterator, the underlying ResultSet will fetch the next bulk itself.
The other alternative is using ResultSet directly that gives you access to PagingState and do all the continuation/paging business yourself. You would lose all the higher level benefits of Spring Data Cassandra.

WCF Data Service : Performance issue while fetching nested entities

My Database Schema :
table : Terminology (ID (PK), Name, Comments)
table : Content (ID (PK), TerminologyID (FK), Data, LangaugeID)
1 - many relationship between Terminology and Content. One Terminology can have any number of content based on different language ID.
Terminology and Contents table may have millions of records.
Now, even thought I fetch some hundreds of record (pagination) from my client side using WCF data Service, after 5-6 attempts, I get time out exception.
_DataService.Terminologies.Expand("Contents").Skip(index1).Take(count).ToList();
If I don't expand my Contents, query works fine :), but I will not have Content Data.
What is the best way to handle this scenario.
Options...
Is there any performance improvement, if I use Include in ServerSide (I mean, writing Custom webget method) over Exapnd in Client Side.
Creating database Views and accessing it over client side.
Creating Stored Procedure, where I can pass my preferred LanguageID and call it from client side.
Is this ADO.NET DataServices build by default wizard?
In any case if your client can access database directly, it will be a lot faster, so if direct db option is available then take it.
If WCF is the only option, then you will have to create your own implementation of Paging Web Service, perhaps even with store procedure that returns multiple recordsets.
On a side note I do not see LanguageId in your service query, and that could slow things down a lot.
_DataService.Terminologies.Expand("Contents").Skip(index1).Take(count).ToList();

Resources