Do I need to two links when building graphql subscription server? - graphql

I am planning to build a graphql application in ApolloServer to support query, mutation, subscription. I have read a lot of articles that subscription is done by websocket. All demos mention that I need to create 2 links, one for http, the other one is for ws.
based on my understanding, graphql spec doesn't include transport layer. I should be able to build one websocket transport to support all query, mutation, subscription.
Is it doable?
Is there any downside if I only use websocket link?

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?

How to handle multi tenancy in graphql server ? Apollo/Prisma/ Hasura anything has this pugin?

Im trying to create a graphql server but in my case i need to setup multiple servers of diffrent customers. How can I implement multitenancy in graphql server?
Tried with apollo and prisma but none of them really worked.
Any libraries or plugin which i can use ?
Depending on the level of data separation needed, multi-tenancy can be achieved with a good attribute-based access control authorization setup at the GraphQL server level. Prebuilt solutions are available with a service like Auth0, or you can roll your own with a library like https://www.npmjs.com/package/passport.
The server lib (like Apollo Server!) can check the user’s tenancy at the time of request with middleware, then route to where ever it needs to go
On the database side, you can separate data by database, table, or just rely on the server level auth, depending on your separation requirements.

AWS Appsync subscription reliable delivery?

We were thinking of using aws appsync for communicating alerts/messages to mobile and web apps using graphql subscription feature. I tried a small example in nodejs using appsync javascript sdk based on tutorial https://docs.aws.amazon.com/appsync/latest/devguide/building-a-client-app-node.html. This is my first time doing graphql and appsync.
Since they use MQTT over websockets, what is QoS used for subscribing? 1, 2
When we use appsyncclient.subscribe Is it our responsibility to verify if duplicate data is coming into the next callback or is it guaranteed based on ID.

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