GraphQL replace Restful API or work with it? - graphql

So I gather GraphQL is a layer which sits in front of your RESTful API and can condense multiple requests down into one. Do you always have to go through a REST API, or can GraphQL talk directly with your MongoDB instead? Or it that what things like AWS Appsync and Hasura do, in that they use GraphQL and talk directly to a DB?
Thank in advance.

It can do either.
https://github.com/Soluto/graphql-to-mongodb
Appsync is a general purpose plugin framework so will need other API's to consume.
Here is a talk given this week about GraphQL vs REST:
https://github.com/MiyamotoAkira/grapqhl-presentation-round1

Related

GraphQl federation server that supports subscriptions

I'm currently evaluating different GraphQl servers in order to find one that supports subscriptions on a federated schema.
Apollo and HotChocolate don't support that. HotChocolate is going to (its on the roadmap) but I can't wait; and Apollo wants me to run a seperate subscription service which I'd like to avoid.
Anybody know of a service that allows me to use subscriptions this way, now?
To be clear: I only need the federation server that supports subscriptions. The single schemas behind may still be served thru hot chocolate.
https://tyk.io/docs/getting-started/key-concepts/graphql-subscriptions/#how-we-are-ahead-of-everyone-else
After some digging, I found this. Looks very promising. They claim to support subscriptions on federation.
have you tried https://github.com/sammysaglam/federation-with-subscriptions?
disclaimer: i am the author of this library.
it uses apollo server express under the hood, and supports federation with subscriptions. it works using schema stitching by converting federation SDL into schema-stitching SDL, allowing full gateway to microservice subscriptions support.

Can GraphQL work without server implementation?

Right now I'm writing a React application.
For education purposes I'd like to write own todo application, using some REST API service to fetch data (https://jsonplaceholder.typicode.com/posts for example)
Can I write a couple of GraphQL queries to get data from this server knowing that their backend implementation does not support GraphQL queries?
In other words, can I use GraphQL on client, and write own backend (or request to one above) as a simple REST API service?

Which instance is the best to create an Apollo Graphql microservice on AWS?

Looking to create an Apollo Graphql microservice on AWS and am looking for the best way to build this on AWS, AWS do have their own Graphql as a service called Apsync but this seems like a blunt tool. Have found lots of suggestions to use Lambda but not much else. The Graphql layer will resolve data from several other AWS microservices.
Certainly don't use AppSync. We used it for a year, and found it's difficult to configure and does not perform well in many types of queries. We ended up using the Apollo Server on top of Lambda. As we use DynamoDb, we wrote our own resolvers (not much effort) as part of using the Apollo Server.

How to wire one/two or more microservice in the TwirpQL Server?

I'm using the GraphQL server which is most-often a gateway that bundles all my different microservices created using gqlgen.
I want to make a switch to the TwirpQL server as I was following the official documentation of TwirpQL. I believe it wants me to wrap every microservice inside it so there will be multiple GraphQL layers one for every microservice.
I don't want to expose the other microservices as Graphql, but rather "just" create one entry point for all the requests and later send them to the respected microservice accordingly.
Can anyone please enlighten me on the correct usage?
Thanks.

How ApolloGraphQL related to GraphQL?

I need to do a research on GraphQL and this confused me.
As I understand, ApolloGraphQL is some kind of framework/service that based on top of GraphQL (just like ExpressJS compared to Nodejs, Laravel framework compared to PHP)
Is that correct?
Thank you very much
GraphQL is a different way to interact with data. Under the hoods, it works through a single API endpoint - typically /graphql. And there is a client tool graphiql to make queries and perform mutations.
Apollo is a framework to implement GraphQL both on the client and the server. Most developers I know use Express-GraphQL to implement the server part as it is the recommended way. And they use Apollo client to connect to the Express-GraphQL server component.
Stephen Grider has a wonderful course in Udemy which teaches GraphQL and Apollo client. And he uses Express-GraphQL over the Apollo server to implement GraphQL on the server.
GraphQL is a language that is mostly used right now as an API on top of your Node.js server (so server-side)
Apollo is a client-side library that is made to consume GraphQL APIs
So, for a popular setup (express + GraphQL + Apollo),
express and GraphQL will execute server-side
The GraphQL API will be exposed a /graphql
Apollo will be executed client-side (in the browser for example) and will consume the API at /graphql
Yes you are correct on that point
ApolloGraphQL is framework for graphql like express framework for rest apis.
You can implement graphql without AppoloServer , but Appolo gives you easy ways to apply graphql that's why we use framework.

Resources