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?
Related
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?
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.
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
Most of the client require GraphQL client library to work with GraphQL API. I know that Tableau supports Rest APIs and wanted to understand if it is possible to use GraphQL based APIs with Tableau?
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.