Anyone did a research on Elastic-search and GraphQL comparison? - elasticsearch

I was trying to understand how Elastic-search compares with GraphQL when they try to solve similar purpose, or does GraphQL uses Elastic-search as a datasource? If anyone done further research share your understanding here ? Thanks in advance.

GraphQL is as the name suggests a query language (mostly for Web APIs). Elastic Search is a data store that exposes a "RESTful" interface. This interface also has some kind of a query language. In that sense they solve different problems:
GraphQL is for exposing data to web clients or apps. It is build to solve challenges faced in client server communication and app development. GraphQL tries to reduce the amount requests and the size of data sent between client and server. Furthermore it give you the ability to extend your API without versioning to keep old clients (e.g. old versions of your mobile app) working.
Elastic search is built to query large amounts of data effectively. Some of their prime use cases are advertised on their website. Usually you would not want to expose the elastic API directly to your client. GraphQL could act as a layer in between that restricts the operations allowed for clients and uses - as you said - elastic as a data source. Or maybe elastic search at some point likes GraphQL so much that they offer an API to write queries in GraphQL that would replace the REST API.
So now that we know that they solve different problems and can be used together, comparing them doesn't really make much sense.

Related

GraphQL, Apollo, Relay … how do they fit together?

When trying to get started with GraphQL, you meet a lot of new terms: Some are related to the concept of GraphQL itself (mutations, subscriptions, …), but there is also an entire ecosystem around it, which – unfortunately – is not always separated clearly from GraphQL itself. However, I find it quite hard to tell where one thing ends, and where the other one starts, and what the differences are, and what is needed when.
So, to name a few of these terms:
GraphQL
Apollo
Apollo Client
Relay
Can you explain maybe in a few sentences what these things (except GraphQL) are, what they are good for, and how they relate to each other (or don't)? And, which important tools / concepts are missing here?
GraphQL The language
GraphQL is a query language. It has a specification that defines the language, schemas and also the execution of GraphQL queries. Learning these things is a great place to start and completely programming language agnostic.
GraphQL implementations
Then there are different GraphQL implementations in different languages that allow you to create a schema and describe how the query resolves to values. Usually these implementations validate the query against the schema that you have defined and take over the execution. Pretty much all of the JavaScript ecosystem uses GraphQL.js but there are many more implementations in other languages.
GraphQL Servers
GraphQL is also transport layer agnostic. That means that usually the GraphQL implementations don't come with an HTTP server. But often we use HTTP to make GraphQL queries, this is why there are some libraries that use these implementations and provide an easy way to create an HTTP server on top (e.g. by providing a middleware for an HTTP framework or coming with a whole server). I think in JavaScript pretty much everyone uses Apollo Server because it brings some more features and it integrates smothly with the Apollo ecosystem and the services offered by Apollo the company.
Apollo Server has also very much popularized the SDL (Schema Definition Language) approach of defining a GraphQL API. With the SDL approach the GraphQL schema is not created using code but by defining the Schema in a special language (also part of the GraphQL spec) and defining single resolver function seperately from that definition. This get's you started quickly but my feeling is that it is not very popular for large APIs. But you can simply pass your GraphQL.js schema to Apollo Server.
GraphQL Clients
When we have a server running we can make queries to the server using a simple HTTP client like the fetch function of the browser. That works pretty well but the power of GraphQL really shines when we use a client that supports caching an automatic query fetching when they are needed. This way we can reach the promised land of declarative data fetching / data dependencies. Facebook has published their own client library that is designed for the unique requirements of a large web enterprise. The library is called Relay and the newer version (breaking from the older version) is usually reffered to as Relay Modern. But Relay is relatively complicated and needs a specific build chain so that GraphQL became really interesting when Apollo released a lighweight client alternative known as Apollo Client. Apollo Client developed a lot over the years and now supports a lot of configuration. Also apollo-react allows to use Apollo Client with React whereas Relay is specifically built for React. With Apollo gaining quite some weight over the years the folks at Formidable Labs have created Urql.
Conclusion
You can use all of these technologies together. Many people simply chose to use the Apollo Ecosystem together, which is probably a solid choice. If you have used Redux before you will probably feel at home using Apollo Client or Urql. If you are building a large app with a performance focus you should consider Relay and understand what contrains this puts on the way you build the GraphQL schema.

Do I really need prisma ORM for graphql?

I have recently started to learn graphql, which at the moment I find really convenient. However, when it comes to connect it with either an object-relational or object-oriented database management system, there is a bit of complexity based on the foundations of each DBMS. For that reason, I started looking for solutions that would make the process more efficient and I found prisma. I understand that prisma is doing all the heavy-lifting mapping my data to any database, however, I see that acts as an intermediate layer between my server and the database. So, my question is:
Does it really worth to use prisma in an application, and if so, how can I explain the overhead that is added by that intermediate layer(in terms of performance)?
I work at Prisma and would love to respond to this.
Prisma's biggest benefit when writing a GraphQL server is that it saves you huge amounts of CRUD boilerplate that you'd have to write in your resolvers otherwise. Paired with GraphQL Nexus, it let's you develop your GraphQL schema programmatically by building upon generated CRUD building blocks while also giving you a type-safe API to access your database.
how can I explain the overhead that is added by that intermediate layer(in terms of performance)?
When hosted alongside your application server, the Prisma server doesn't really add any performance penalties. Also note that we're currently rewriting the query engine that's running inside the Prisma server in Rust, this will make the Prisma server optional and you will be able to use Prisma as a simple library (similar to how you'd use TypeORM or Sequelize). The query engine then runs as a binary on the same host machine as your web server and connects to your database from there.
UPDATE: July 22, 2019: We've released a first version of Prisma 2. You can find all infos here.
I'd recommend you take a look at the GraphQL Nexus docs to learn more about the concrete workflows. Please let me know if you have any further questions, I'm happy to help :)

Where the data is Storing in Graphql

I started to use graphQl with react relay. And I followed some tutorials and I can able to get and post with the help of mutations and queries. Everything works fine but my question here is,
Where qraphql is saving the data and fetching that for us
for example: If I get data from database mean's I can go through into particular DB/ TABLE. Likewise, i want to know where graphql is storing the data.
i searched many sites, They are telling how to use qraphql but I cant able to find an answer to my question. I need clarification in this area. Can someone help me out with this.
GraphQL is a query language for your API, and a server-side runtime for executing queries by using a type system you define for your data. GraphQL isn't tied to any specific database or storage engine and is instead backed by your existing code and data.
You can connect any database using GraphQL.
As I understand you are trying the mutation and queries with some hosted engines.
Please go through this reference and set up the GraphQL engine on your side.
GraphQL, unlike a database level query languages like SQL, is an application level query language. It's up to programmer to create necessary logic - in most server implementations realized by using resolver functions - to make a domain described by GraphQL Schema a reality. This includes any form of persistence.
The GraphQL is using localStorage provided by your browser by default if there is no other storage are provided.

Replacing REST calls with GraphQL

I've recently read about the advantages (and disatvanteges) of GraphQL over Rest API.
I am developing a webpage that consumes several different Rest APIs and Soap services. Some of those services are dependent, meaning that a result from Rest1 will be passed as a parameter to Rest2 which will be passed to Soap service for a final return value.
From what I understood, GraphQL deals with multiple data sources and query nesting, but I have not yet understood if it will handle those nested dependent queries.
Can anyone that worked with several data sources that are dependent with GraphQL tell me if it can be done? My project should be up in 2 weeks and investing time in learning and setting up GraphQL and ending up not using it because it's not supporting my case would be a big failure for me.
Note: the APIs and services are not mine, I am consuming them from an outside source
I'm assuming you haven't yet setup a GraphQL server. Once you do, you can see how this isn't too difficult. So, I'd recommend you setup your own server first. The Egghead Course, "Build a GraphQL Server" got me started, but it's not free.
In essence, you'll be setting up your schema then defining how to resolve with data. When you resolve, you can setup an express server to query a database, or you can hit a REST interface, or hit your SOAP interface. How you retrieve the data is up to you, so long as you return it in compliance with your defined schema.
Hope that makes sense. Mocking up a mini app to demonstrate is possible, but since I don't have one handy, this is the best advice I can offer.

What is the underlying backend of graphql?

I sort of understand how the graphql engine works with its querying ability etc.
How does graphql actually connect to the backend datastores like postgresql etc.
Is this a nodejs application or a more scalable backend written in java/golang could be used by graphql?
Sorry I'm not sure I understand the various components required to use graphql and hoping someone could explain that to me.
I believe if I understand it correctly you define the back-end for your GraphQL implementation. See here for supported languages: http://graphql.org/code/
One of the primary things GraphQL does is allow the client to define what gets returned rather than the Api, you build out your Api with the GraphQL libraries and define schemas to map your data logically.
Here's a good article that shows how this can be done with React for the client and Node for the back-end: https://www.sitepoint.com/graphql-overview/

Resources