Delbert  Ferry

Delbert Ferry

1622282384

How We Built GraphQL Subscriptions with Apollo

A real-world example
At Scaphold, we manage a lot of infrastructure to make sure our customers’ APIs stay available and performant. One of our core features is a graphical schema designer that allows you to easily define the GraphQL schema that will come to define your Scaphold API. What you don’t see when playing around with our schema designer, however, is a complex migration system that makes sure your API’s database is always up to date and in adherence with your schema. When you make a migration to your schema, the machine that fields the migration request will make the necessary changes to your database so that your API stays in sync.

#graphql #graphql subscriptions #apollo

What is GEEK

Buddha Community

How We Built GraphQL Subscriptions with Apollo
Delbert  Ferry

Delbert Ferry

1622282384

How We Built GraphQL Subscriptions with Apollo

A real-world example
At Scaphold, we manage a lot of infrastructure to make sure our customers’ APIs stay available and performant. One of our core features is a graphical schema designer that allows you to easily define the GraphQL schema that will come to define your Scaphold API. What you don’t see when playing around with our schema designer, however, is a complex migration system that makes sure your API’s database is always up to date and in adherence with your schema. When you make a migration to your schema, the machine that fields the migration request will make the necessary changes to your database so that your API stays in sync.

#graphql #graphql subscriptions #apollo

Delbert  Ferry

Delbert Ferry

1623293670

GraphQL Subscriptions in Apollo Client

GraphQL subscriptions are based on a simple publish-subscribe system. In our server-side subscriptions package, when a client makes a subscription, we simply use a map from one subscription name to one or more channel names to subscribe to the right channels. The subscription query will be re-run every time something is published to one of these channels. We think a common pattern will be to publish mutation results to a channel, so a subscription can send a new result to clients whenever a mutation happens. This is why some people call subscriptions the result of someone else’s mutation .

#apollo client #subscriptions #graphql

Eleo Nona

Eleo Nona

1600219097

How to Build Apollo GraphQL Server From Scratch

What is GraphQL

GraphQL is a query language and a server-side runtime that is used to request data from the server. The first thing that comes to mind when hearing the term “query language” is SQL. Just as SQL is used for querying databases, GraphQL is a bit like SQL but for querying web APIs as it eliminates the need to repeatedly develop or change existing end-points. GraphQL also enables the client/front-end to retrieve exactly the data they have requested and no more. This means that, within a single request of GraphQL, you can traverse from the entry point to the related data (whereas in RESTful API you have to call multiple endpoints to fetch similar results).

The following example will help you to understand this better. Let us consider an object person which has the attributes name, age, email, and contactNumber. Suppose the front-end only needs the name and age of the person. If we design a REST API, the endpoint will look like api/persons, which will end up fetching all the fields for the person object. The issue arises here because there is no easy way to communicate that I am interested in some fields and not others (which causes REST API to over fetch the data).

#graphql #nodejs #apollo-server #graphql-apollo-server

Delbert  Ferry

Delbert Ferry

1622276694

Apollo interns on GraphQL Radio

Shadaj Laddad
Shadaj is a senior at Lynbrook High School, and has been programming for a long time. He’s been historically interested in Scala, but was working mostly in JavaScript during his internship. Here’s what he worked on:

  • Subscriptions tutorial: Shadaj continued the Full-stack GraphQL tutorial with two steps about subscriptions: [Server-side] and [client-side].
  • Apollo Cache API: He refactored Apollo Client internals to separate out the internal GraphQL cache implementation behind a clean API. In Apollo Client 2.0, the cache will be completely pluggable, so that people can integrate caches based on different technologies like MobX, and build new features like offline support.

#graphql #graphql radio #apollo

Delbert  Ferry

Delbert Ferry

1622278191

GraphQL Subscriptions on the Server

GraphQL Subscriptions
To notify the client when messages are added to a channel, we’ll use GraphQL subscriptions, which allow the client to make a query and be notified of new results in the case of specific, server-side events. In our implementation of the server, we’ll use an Express server with WebSockets for pushing updates to the client.

In this tutorial, we’ll first add a subscription that notifies the client about new messages. Next, we’ll add a field to our GraphQL schema and implement a resolver for the subscription. Finally, we’ll use an in-memory pub-sub object that will handle passing along notifications about added messages.

#graphql #subscriptions #graphql server