Can someone brief me and help me decide which one to go with between AEM QueryBuilder Vs AEM GraphQL API?
I see that you have option of persistent queries in GraphQL do we have any caching options in QueryBuilder? How can we leverage it to the fullest?
Would using QueryBuilder against GraphQL mean drop in performance or it should be fine to use the same?
In which cases would one suit better over other can you have a brief about it? I know that when you have sorting, pagination, etc operations you can't use GraphQL but what about all the other scenarios, would I have issues in performance or any advantage like caching over QueryBuilder if I use GQL or it would almost be the same?
Related
For example, if I want to build a series of Lambda micro-services which hit an ElasticSearch instance, is this an anti-pattern? I saw that there was a project a while back called Ramses, but is not supported anymore, so I am wondering if there's a better way to achieve these results that I'm simply not aware of.
I know that ElasticSearch has its own REST API as well, but I want to tailor the interface to our data and provide a more limited but concise request syntax.
After learning about Graphql, I have understood that it has many advantages over Rest API, one of which most commonly mentioned is to do with convenience.
But does Graphql actually offer any performance increase over Rest API though?
This is a very general question, and therefor the general answer - it depends.
It depends on your use case, if you have nested objects that require multiple calls in a 'standard' REST architecture like #RAVI_SINGH answered, than yes, graphql can decrease the number of calls requires and thus increased performance. But this really depends on your use case.
On the other hand, if you don't have such cases, and don't need the 'power to the client' capabilities graphql provides, than you do pay something in performance, when doing all the selection set calculation for example.
So like almost everything, there's good and bad in graphql, and it can improve the performance or not, depending on your model and how you implement and use it
Yup definitely. If you just google GraphQL vs. REST you will get many answers but I will give you one example which will explain everything.
Let’s suppose you want to get some books' details with their respective reviews from your REST server which has separate endpoints -- for example, /books and /reviews
REST: If you are making a direct call to your REST server then first you have to make a call to get all book details and then for each book's ID you will make a call to get its review from the /reviews endpoint. This way you end up making n+1 calls.
GraphQL: If you are using GraphQL as an intermediate server, you will write only one query that will do everything for you. This means your GraphQL server will understand the query and in one query only it will first fetch all the book details and then it will fetch review for each book.
Using Data Loader you can optimize your GraphQL server even more.
Refer to this link to learn more.
I have been reading about the articles on the web about the benefits of graphql but so far I have not been able to find a single benefit of it.
One of the most common benefits mentioned in those articles are below?
No Overfetching with GraphQL.
Reducing number of calls made from client side.
Data Load Control Granularity
Evolve your API without versions.
Those above all makes sense but it is not the graphql itself that provides these benefits. Any second layer api written in java/python or any other language would be able to provide this benefits too. It is basically introducing another layer of abstraction above the data retrieval systems, rest or whatever, and decoupling the client side from that layer. After you do that everything you can do with graphql can also be done with any other language too.
Anyone can implement a say scala server that retrieves the data from various api's integrates them, create objects internally and feeds the client with only the relevant part of the data with total control on the data. This api can be easily versioned and released accordingly. Considering the syntax of graphql and how cumbersome it is and difficulty of creating a good cache around it, I can't see why would you use it really.
So the overall question is there any benefits of graphql that is provided to the application because of the graphql itself and not because you implement another layer of abstraction between your applications and your api's?
Best practices known as REST existed earlier, too.
GraphQL is more standarized than REST, safer (no injections) and syntax gives great flexibility in the area of quickly changing client needs.
It's just a good standard of best practices.
I feel GrapgQL is another example of overengineering. I would say "Best standards and practices" are "Keeping It Simple."
Breaking down and object and building a custom one before sending it to the client is very basic.
There are now REST apis for Mongodb and redis.
I can connect to those databases with my language's driver.
Or I can use the REST api. I understand that the REST api is easier to grok, and easier to convert from language to language. But there's less features.
But is there any reason to use the rest api if I'm already doing fine with the language driver?
Thanks.
In my opinion a RESTful API is useful when you have to integrate multiple different clients in heterogenous environments. It's also good when you need features that are already solved for HTTP – like caches or load-balancing.
REST resources are supposed to capture use-cases of your application. I find it highly unlikely that an API to a database would do that for you. Mostly like the native language driver is the appropriate choice.
Rich web clients can talk directly to it, without any server side mediator. Also, for instance, if you have a JCR repository with NoSQL connector on hostA and NoSQL store on hostB, you're glad for RESTful api.
I want to implement declarative authorization with mongoid. But cannot succeeded. It seems like declarative authorization works with ActiveRecord Only. Can I let it work with MOngoid and MongoDB? Any Ideas.
Declarative Authorization is a conceptual model for explaining who has access to data. It's also a ruby plugin that implements this conceptual model.
The plugin probably doesn't apply to MongoDB directly. So you'll need an ActiveRecord provider form Mongo. There is one here. Then you can use the Declarative Authorization plugin with the ActiveRecord provider.
I had found a fork that could integrate declarative authorization and mongoid. Here is it:
http://github.com/opusmagnum/declarative_authorization/commit/79ccff34233b2371299c3ff66a18ad37be08d9c6