fabiochiu/medium-articles huggingface dataset:
Cypress: Mocking GraphQL Requests
By: Viskantas Juodenas
Tags: GraphQL, Mocking, Cypress, Typescript, Testing

Let’s See Some Examples!

We have created a suite of helpers that allows us to freely mock and control GraphQL operations when running Cypress tests. Though for this article we will display a barebone version of how we approach mocking GraphQL operations.

As an example, here is a GraphQL query operation that our Frontend might execute. Let’s see how we would mock this request.

productList query

Because we convert GraphQL schemas to Typescript types, we already have the response type in our Frontend code.

productList query response type

We can reuse this Typescript interface to add type safety to our API mock data. This way we will be sure that the response mock data is always correct. If the API contract would change for the productList query, after re-generating graphql.types.ts file and running Cypress tests we would receive a Typescript error telling us that the response mock data is outdated and no longer reflects what the products query would return.

Response mock with type safety

Now we need to use this data to mock the productList GraphQL operation. Cypress does come with a cypress.route() function that allows mocking network requests, but it does not work as well for GraphQL requests. For GraphQL, it’s common practice to have all queries executed under a single request endpoint. We needed to create a custom helper function that allows us to mock requests not by URL, but by the GraphQL operation name.

Here is a simplified version of what we use. A helper function is going to mock all window.fetch calls that are executed with /graphql endpoint. The fetch stub will look for mock data based on the GraphQL operation name. If request mock data is found, it will be used as the request’s response. If not — the request will not be mocked.

With everything set up, we can effortlessly mock GraphQL requests inside Cypress tests 🙌
Abstracting protected GQL fields with Apollo Server
By: Kenny Hammerlund
Tags: GraphQL, JavaScript, Nodejs, Graphql Resolver, Apollo

In our tech stack, we are starting to move into creating more protected fields. In this article, I am going to share a function that has become useful to me and reduced some of the redundancy in checking if a viewer has access to a field on a type.

Preface: Using the Viewer Pattern

This is a common GQL Pattern that uses user based fields. If you need more information here are a couple of great resources

* https://stackoverflow.com/questions/37635328/what-is-the-meaning-of-viewer-field-in-graphql

* https://medium.com/workflowgen/graphql-schema-design-the-viewer-field-aeabfacffe72

On Apollo server the credentials are generally stored in the context

* https://www.apollographql.com/docs/apollo-server/data/resolvers/#the-context-argument

A resolver “Wrapper”

There are plenty of ways to create auth, that’s beyond the scope of this article. For the rest of this article lets refer to an auth implementation as authFunction()

I found myself writing this code more than I would like when I was building out the graph.

export const resolvers {

AGraphType:{

aProtectedField: (parent, args, ctx, info)=>{

authFunction(ctx, …)

//rest of the function

//return some value

}

}

}

This really isn't an issue when you have other code to write within the resolver.

BUT!

What about when the parent object holds most of your data. I do it commonly as the parent will call a repo or DB Call and pass it to the children

AGraphType: {

id: 1,

toys: [‘car’,’truck’],

isFun: true

}

Writing the code below seems like trash (as the YouTubers say), It can get out of hand quickly. It is possible to protect the parent type if you want but most of my use cases have a mixed bag of protected and public fields. Another possibility is to do an interface or union that provides protected fields as well but my preference is to avoid interfaces & unions if I can.
Incremental Data Delivery with GraphQL defer and stream
By: Yosuke Kurami
Tags: Typescript, GraphQL

Quramy/graphql-streaming-example

You can't perform that action at this time. You signed in with another tab or window. You signed out in another tab or…
サーバサイド(Spring Boot)でGraphQLを実行する
By: Masanobu Uenaka
Tags: Java, GraphQL, Spring Boot

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
Build Your Own Puppy Playdate Tinder App With Slash GraphQL
By: Tyler Hawkins
Tags: GraphQL, JavaScript, React, Database, Programming

Build Your Own Puppy Playdate Tinder App With Slash GraphQL

A corgi living his best life (Source: Pixabay)

Every dog owner wants to find the perfect friends for their new puppy. Now we have an app for that! You can browse through various puppy profiles and swipe right or left to find your new puppy friend. Setting up puppy playdates has never been easier.

OK, not really. But we do have a wacky demo app built with React, Material-UI, Apollo Client, and Slash GraphQL (a hosted GraphQL back end from Dgraph).

In this article, we’ll explore how I built the app and also look at some of the basics of the technologies I used.

Ready to unleash the fun?
GraphQL Resolvers And Avoiding Over-Fetching
By: Syam Dorjee
Tags: Performance, GraphQL, Java, Design, Spring Boot

GraphQL is an alternative of REST or SOAP. GraphQL beauty lies in how it works under the hood. But here we will be learning how can we write our resolver for query-based language GraphQL.

A badly written resolver may solve your requirements but sometimes it can cost you heavy resource utilization without any awareness. though what I am explaining here might not go with your requirements but these things we should keep in mind while writing a field resolver.

Let’s consider a use case. Where we need to fetch user activity. Sometimes we need to fetch only FOOD information. Sometimes TRAVEL info only or both. One way we can do by writing two different queries but we are going to avoid that.

I am using Java Graphql Tools and I believe you are familiar with GraphQL basics.

Here we have defined the UserActivity schema above.

And we have defined our query.

Let’s see the Java classes now.

So we have declared our Food and Travel Class and UserActivity return class.

Now we are looking at the service where we fetch our result from DB( Using Spring Data JPA).

UserService returns you user object which is required to get userId ( i am using JWT Token which gives me user details )

So, What’s wrong with the above service.

If we need food info only, travel info also be loaded. If we need travel info only, food info also be loaded.

By using resolver we can easily make them independent and save some resources and time.

Let’s see how we can design our resolver. We are going to re-write the following things.

UserActivity.class UserActivityQuery.class UserActivityFieldResolver.class(Newly Added)

Note: schema remains the same

So UserActivity no longer contains Food and Travel. So GraphQL will look for a field resolver marked with UserActivity class to resolve it.

Field resolver will only resolve both methods if you ask for both. If you ask for food then it will only resolve food. Same for Travel.

So, we have seen how little awareness and knowing resolver can save some resources and time.

Thank you.
Beginner’s Guide to GraphQL
By: Harsh Patel
Tags: GraphQL, Web Development, API, Programming, Software Engineering

Let’s talk about one of the biggest challenges in web development: connecting your app to the database. While you may not share similar ideas, this is one of my favorite parts of server side development, so this tutorial will show you my experimental and realistic strategies that make this work.

First of all, once you start with the details, it can be very difficult as there are TONES of various options to choose from. Should you choose older MySQL, MongoDB, PostgreSQL, or older GraphQL? When you think, “What’s the big difference?” No worries people, you’re like me, I was also thinking the same.

You are using this guide

I am well aware that there are hundreds of other guidelines online about this same topic, and I can confidently say that I have looked at most of them. When I first started with the details and GraphQL, I was very confused. A myriad of resources and various methods can leave you wondering, “Should I do it this way or that way?”
GraphQL Kullanım Alanları ve Örnek Bir Uygulama
By: Mehmet Ozan Turhan
Tags: GraphQL, Rest Api, Apollo Server, Expressjs, Apollo

ozanturhan - Overview

Welcome to my page! Since 2012 I have been working as a Software Developer. I manage my projects carefully in…
Awesome write up!
By: Rich Burdish
Tags: Federation, Mutations, Apollo, GraphQL

Awesome write up! Would be interesting to hear a follow up on how Netflix addresses mutations in the event that the changes span multiple schemas. Assuming each schema’s backend service would be responsible for orchestrating calls across any necessary dependencies, this may raise an interesting problem when propagating the updates back to the frontend clients
Introducing Artemis: Deno’s First Analytics Tool for GraphQL Queries
By: Stella Liao
Tags: Analytics Tool, GraphQL, Analytics, Deno, Software Development

What technology does Artemis use?

Deno is a secure runtime for JavaScript and TypeScript, providing a built-in package manager via ES module imports from anywhere on the web. Deno was built by Ryan Dahl, the original creator of Node.js, and is poised to offer a competitive alternative to Node’s dominant JavaScript runtime.

GraphQL is a query language and server-side runtime for application programming interfaces (APIs) that prioritizes giving clients only the data they request and nothing more. GraphQL is designed to make APIs fast, flexible, and developer-friendly.

Artemis arrives at the intersection of these two pioneering technologies. Our dynamic GUI, compiled using Aleph.js, allows users to send query requests to external APIs that use GraphQL. Under the hood, sophisticated and performant algorithms calculate performance metrics for each query request and Artemis immediately displays them as accessible and digestible analytics for developers.

We couldn’t be more excited to share Artemis with you. Let’s take a look.

How does Artemis work?

Simply enter the endpoint URL you are testing and select the number of times to run the query, then watch as Artemis visualizes your results in real time.

Yep, it’s that easy.
GraphQL facade for REST API with AWS Lambda
By: Gary George
Tags: GraphQL, JavaScript, Rest Api, Nodejs, AWS

Here is a bit of an explanation of the main pieces of this project.

Node setup:

To get our Node instance running we only need two files:

server.js

See here, This file is a basic file for starting our Node application.

app.js

See here, This sets up our express server and our GraphQL endpoint.

Interesting to note in the below block, graphiql: true Allows us to use the GraphiQL tool mentioned above.

app.use( ‘/’, graphqlHTTP({

graphiql: true,

schema: GraphQLSchema

}));

Lambda setup:

If you are only interested in getting this running in Node you can skip this.

However, if you would like to get this running on AWS then you will need to create a serverless.yml file and the corresponding handler function.

Serverless.yml

See here, This file sets up everything you need with AWS API Gateway, enabling the endpoints for using GraphiQL in AWS.

This is the block that handles the creation of the routes, The great part about this is it saves you having to log in and manually create the routes.

functions:

getPosts:

handler: lambda.handler

events:

- http:

path: posts

method: get

cors: true

- http:

path: posts

method: post

cors: true

lambda.js

See here, The handler function will be triggered when our API Gateway routes are invoked.

We are using the npm package ‘aws-serverless-express’, This allows us to Run serverless applications and REST APIs using our existing Node.js application framework, on top of AWS Lambda and Amazon API Gateway.

GraphQL setup:

Everything you need for the GraphQL schema set up can be found in this directory.

We have our queries, resolvers, types, and mutations separated into separate directories.

schema.js

See here, Our schema js file is the heart of our GraphQL setup, here we specify our queries and mutations that we have configured.

Our Query (see here) is linked to our resolver (see here), This is where you would make your API call to retrieve data, in this example, I am returning a static JSON object to simulate data coming back from an API.

You will notice in our Query that we reference our type (see here), This assures that the data we are returned is exactly what we expect, allowing GraphQL to work its magic and work as expected.

Our Mutation (see here) Lists out the payload it expects to receive along with the types of data expected. If a sufficient payload is passed it will make it into the resolve function.

The resolve function is where you would fire off the payload to your API for insertion or update, then return the mutated response. For this example, we will just be returned the args that we sent.

Wrapping up:

I hope this helped to demystify how to implement GraphQL.

As mentioned above clone the boilerplate and get started.
6 Tricks for Next-Level CRUDs
By: Joey Anuff
Tags: GraphQL, Cassandra, React Query, React Hook, Nextjs

NEXT.JS 10 // REACT-QUERY // AXIOS // DATASTAX DOCUMENT API

6 Tricks for Next-Level CRUDs

To follow along with this demo, initialize a free Cassandra database at DataStax, whose super-simple new Documents API we’ll be using for our backend. Make note of your username, password, cluster/database ID, region, and namespace. Init a new Next.js app and install these extra dependencies:

npm install axios axios-auth-refresh react-query react-query-devtools sass

I was looking for a clean, reusable React hooks-based approach for all my endpoints, something lighter than the full Apollo Client suite–maybe just a pattern or two, some smart but minimal approach to all my JSON traffic.

1. CACHE YOUR DATA WITH A REVALIDATION LIBRARY

React Query more than fit the bill: a low-carb request wrapper that follows the “stale-while-revalidate” approach to data fetching. Vercel’s similar SWR hook library also looked like a good option (Vercel being the creators of the Next.js framework) but React Query author Tanner Linsley’s polished docs and devtools made his library an almost irresistible choice.

2. SET YOUR DEFAULTS WITH AXIOS

Different APIs are finicky about different headers. Any day I can DRY up my boilerplate with some global defaults is a great day.

Those are my variables, get yours at DataStax.

3. REFRESH TOKENS WITH AXIOS-AUTH-REFRESH

Authentication panic is common, what’s really refreshing is accepting help, as I did when I installed this calming token authenticator.

Axios-auth-refresh boilerplate, except for ‘X-Cassandra-Token’ and the pause config.

The token in local storage is just for debugging.

4. PRE-LOAD YOUR QUERY CACHE (WITHOUT PRE-FETCHING)

My favorite React Query trick: instead of requesting data for every detail view, React Query builds a cache from your first paginated GET.

Load up the cache from your app’s first GET

5. EXPORT SELF-DESCRIPTIVE HOOKS

All our CRUD operations are now simple and exportable. React-Query lets us specify our cache policy during and after each query or mutation.

react-query’s useQuery and useMutation hooks

6. SYNC EVERYTHING WITH YOUR HOOKS

Our Items index now runs with just two hooks, an items query hook and an addItem mutation hook. Each comes with a full menu of lifecycle booleans.

The items hook fetches the data and sets the cache. The addItem hook invalidates them.

Changes on the detail page are reflected instantly–and reverted if they fail–using the Optimistic Update strategy.

The saveItem hook on each item’s dynamic route page uses Optimistic Updates.

With React Query’s devtools drawer open, we have perfect visibility into the state of our cache.
Basic Components of a Subgraph
By: Jerry Okolo
Tags: The Graph Network, GraphQL, The Graph Protocol, Subgraph, Data Curation

In this post, I’m going to share with you what a subgraph is and its fundamental components. This will help you understand how it tracks, structures, and indexes on-chain data for anyone to query.

A subgraph defines which data The Graph will index from Ethereum, and how it will store it. It consists of three main components:

Subgraph Manifest

Subgraph Schema

AssemblyScript Mappings

Subgraph Manifest

The subgraph manifest is a file that tracks events on-chain. It hones in on specified smart contracts and listens for when events or functions are triggered. I’m going to use a subgraph I developed as an example.

As you can see in the image below, the subgraph manifest tracks a specified smart contract on-chain for certain events or function calls. An event is emitted whenever someone redeems an mETH token. So this tells the graph node to focus on that event on-chain.
WorkflowGen 7.22.0
By: Wfg Team
Tags: Workflow, GraphQL, Release Notes, Nodejs, Sql

WorkflowGen 7.22.0

WorkflowGen version 7.22.0 introduces the new EXECSQL workflow application, which allows you to execute one or multiple SQL queries in a process. For example, you can use EXECSQL to retrieve information via SELECT queries in order to use the results in process conditions; INSERT, UPDATE, DELETE, SCALAR and PROCEDURE queries are also supported. Usage instructions, lists of required and optional parameters, and examples of queries are available in the EXECSQL Workflow Application section of the WorkflowGen Administration Guide.

EXECSQL parameters in the Workflow Designer Edit action panel

Enhancements & performance improvements

As of version 7.22.0, the Form Designer attachment tool supports PDF file preview in Advanced Mode. As well, the completeFormAction function used by the different APIs (GraphQL, webhooks and SOAP) now supports and generates file attachment download links in the form archive for associated input file context parameters. In the Directory Synchronization module, system memory usage and error management for Active Directory and LDAP synchronizations have been improved for better performance.

Node.js version updates

The Node.js-based modules now require Node.js version 14.15.1 LTS. GraphQL has been updated to version 4.2.0, webhooks to version 5.5.0, Auth to version 2.4.0 and SCIM to version 2.1.0.

Head over to the WorkflowGen 7.22.0 release notes for all of the details.
GraphQL Data Fetching with Apollo Client in React
By: Luis Guerrero
Tags: GraphQL, React, JavaScript, Programming, Apollo

The Setup

Before we start getting fully into the Apollo Client, let’s start by creating a React project, or you can use the next base React project since the code we’re going to explore below is based on it.

If you want to learn more about this base project, don’t forget to check the article where I explain what’s included and how can it help you to make your project’s life easier.

Let’s start by cloning it with the next command:

As mentioned at the beginning, to be able to connect to a GraphQL API, we’ll make use of the Apollo Client library, providing us with a lot of goodies like in-memory cache, local state management, etc.

To install the library, we need to run the next command in the terminal:



yarn add cd react-graphqlyarn add @apollo/client graphql

After the installation finishes, we’re ready to start configuring our React project.

For our examples, we’re going to use the Countries GraphQL API, which provides us with information about countries, continents, and languages
Turning legal requirements into interactive website features: Part 1
By: Gabriel Diaz
Tags: GraphQL, Interactive Design, D3js, JavaScript, Highcharts

Introduction by the Product Manager: Life Insurance Illustrations

Whole life insurance is arguably the most important product in life insurance. And when you sell it, you have to provide legally mandated documentation to the customer, called an illustration; but illustrations are complex documents that are often not easy to understand. Even professionals have trouble understanding illustrations, some of which can be up to 20 pages long. They’re usually a PDF, and look something like this:

Our Coverpath products aim to rebuild legacy insurance systems. We wanted our Coverpath customers who buy Whole Life insurance to have an interactive explanation of the benefits that helped customers and advisors dig into and actually understand the benefits of Whole Life Insurance.

So we decided to innovate.

The end result

Our product and design team interviewed advisors and customers, and created a plan for the Visual Sales Tool for Whole Life Insurance: An online interactive webpage that was easy to understand, and even fun to use:

This article continues in our next post by Srishti, the software engineer who built the new feature. You can read it here: https://medium.com/haven-life/understanding-and-visualizing-life-insurance-illustrations-8f4eba6cafe0
GatsbyJS — Building Stallion Websites That Outrun the Rest
By: Daniel Bergmann
Tags: GraphQL, JavaScript, Web Development, Gatsbyjs, Reactjs

Working with GatsbyJS, the React-based, GraphQL powered static site generator has been a wild ride so far. Build on top of that a modern CMS like Prismic and you can’t go wrong.

You could implement this technology into almost any industry and it would work. Even better than using dinosaur CMSs like *cough* WordPress. *cough*

But people don’t like change so how do you persuade the client or stakeholder that newer is better?

Is going static the future? Do we need the future, yet?

Bringing such a product to your boss and shouting like a monkey “hey, use this! This is the future!”.

That might not be the best way to do it but maybe there’s a better solution.

Whats Gatsby?

GatsbyJS is a combination of the ReactJS best of the best. It’s an open-source community empowered beast with a bunch of good reviews on the internet.

The developer experience is great as it weaves together the best parts of React, Webpack, react-router, and GraphQL. It has a bunch of plugins and is constantly evolving so both the developer and the client can live happily ever after.

GatsbyJS is said to be a static site generator, however, as I dive deeper into the abyss of the Gatsby development community I find out it is a much grander and generous compadre to find.

It is not like the old static generators people are used to.

It’s really a Stallion-site generator.

It uses powerful reconfiguration to build a website that uses only static files for incredibly fast page loads, service workers, code splitting, server-side-rendering, intelligent image loading, asset optimization, and data prefetching. I was told Usain Bolt couldn’t outrun Gatsby, but that's a topic for some weird podcast.

You code up your site in your favorite code editor and run gatsby build in the command line. Gatsby then transforms your code into a lean, mean code-spilling stallion of a directory in the shape of a single HTML file and your static assets.

GraphQL

GraphQL is what gives GatsbyJS the powers to make stallion websites that it does.

GatsbyJS utilizes GraphQL to build the data layer. Data from APIs, the Headless CMS you use, or JSON. When you run gatsby build it creates an internal GraphQL server from all of the data.

All in all, working with static sites is cheaper and easier for both the developer and more importantly the client. It’s modern and worth digging into if you dig digging dig worthy diggables.
Apollo Federation in Golang
By: Manato Kuroda
Tags: GraphQL, Golang, Database, Programming, Apollo

What Is Apollo Federation?

Apollo Federation is a technology that allows you to compose multiple GraphQL services into a unified data graph.

Apollo Federation can expose one graph for all of the data in service without experiencing heavyweight development or a large code base like a monolithic architecture.

It enables us to collaborate with multiple teams on shared data and to separate concerns to work on any features without interfering with each other.

The idea of this is based on microservice architecture, so you can divide the implementing graphs across multiple composable services.
Using GraphQL .NET Client in .NET 5
By: Mahdi Taghizadeh
Tags: Dotnet, GraphQL, Csharp, Dotnet Core, Dotnet 5

GraphQL for .NET is one of the open-source libraries available both to create and consume a GraphQL API and there are dozens of blog posts and tutorials available to learn more about it.

In this quick post, I want to show you how to use GraphQL.Client and define the client in your Startup.cs and inject it into a controller in ASP.NET Web API.

Once you’ve created your Web API (or any other type of .NET project); you need to add its NuGet package:

dotnet add package GraphQL.Client --version 3.2.0

If you want to use Newtonsoft.JSON, feel free to add that too

dotnet add package Newtonsoft.Json --version 12.0.3

The next step is adding a GraphQLClient to your Startup services to be able to inject them into your controller later:

public void ConfigureServices(IServiceCollection services) {

services.AddMicrosoftIdentityWebApiAuthentication(Configuration); var graphQlClient = new GraphQLHttpClient(Configuration.GetSection("MyGraphQLApi").GetSection("ApiUrl").Value, new NewtonsoftJsonSerializer());

graphQlClient.HttpClient.DefaultRequestHeaders.Add("Authorization", Configuration.GetSection("MyGraphQLApi").GetSection("ApiToken").Value);

services.AddScoped<IGraphQLClient>(x => graphQlClient); services.AddControllers();

}

It’s simply getting API URL and Token from “MyGraphQLApi” section in your appsettings.json file (so you don’t need to repeatedly do this in your methods) and adds it to your services.

Then you can easily inject it into your controller:

private IGraphQLClient _mondayClient;

public MondayController(IGraphQLClient mondayClient) {

_mondayClient = mondayClient;

}

Now you can use this injected instance of GraphQLClient in your methods:

var request = new GraphQLRequest {

Query = @"query Project($boardId: [Int], $groupId: [String], $columnsIds: [String])

{

boards (ids: $boardId) {

name,

groups (ids: $groupId) {

id

title

items {

name

column_values (ids: $columnsIds) {

id

title

value

}

}

}

}

}",

Variables = new { boardId = new List<int> { 379551383 }, groupId = new List<string> { "new_group80740" }, columnsIds = new List<string>() { "text73", "text7" } }

}; var response = await _mondayClient.SendQueryAsync<Data>(request);

In the example above I’m getting some data from Monday.com API and I’ve passed parameters using Variables.

If you have a complicated data model returned in JSON, you can use tools like JSONUtils or JSON2CSharp to generate your model classes from the JSON and use it to deserialize the response to objects.

Enjoy!
Uniswap V2 — How I lost money against “unfair” contracts!
Tags: Dex, Python, GraphQL, Uniswap, Dextrading

There is great hype going on and its called DEX trading and one of the biggest happens at Uniswap. To be totally fair its great thing just it has its own flaws and here I am going try to expose few of them.

To start trading at Uniswap you need some wallet, I am using Metamask and few ETH balance and as you ready to go. Than is cheaper to trade if your ETH are wrapped to WETH (trades can be done from other symbols as well as USDT just WETH is most popular and roghly 80% of trades are done with it).

Once you are at uniswap.com there is cool search option to find contract. And let’s see how many of them are there via Python and GraphQl and what kind of data we can get.

You can play in the sandbox: thegraph.com or use the python code bellow:

So that’s how I got data down and made some script that follows momentum and started trading various tokens with no extra safety. This is the point when I say: Please do not do that to avoid making mistakes as I did!

My advice is to limit trading to only tokens that are trusted and are 100% sure that will return your balance at any time.

Personally, I solved that by avoiding newly created tokens and am trading only well established ones. That message “if you purchase an arbitrary token, you may be unable to sell it back” was simply ignored at my end at first.

So that’s how happened that I lost few hard earned ETH’s or better to say WETH’s.
Creating GraphQL API with C#
By: Tooraj Helmi
Tags: Graphql Net, Dotnet, GraphQL, Csharp, API

Introduction

GraphQL was originally introduced by Facebook to be used by React based clients. For people who know React is comes in two flavors: React.JS used to create SPA web applications and React.Native used to build native mobile apps. Both of these technologies are created on top of JavaScript. Facebook website and mobile apps are themselves created using React.

In order to provide an effective way to create APIs to be consumed by the client apps, Facebook introduced GraphQL which was also implemented in JS and could be used as an alternative to node.js to build APIs by JS programmers.

GraphQL APIs offers two major advantages over REST APIS:

Using GraphQL the caller can specify what specific properties of an object it is interested in. If offers a subscription mechanism to update the client in a real-time fashion.

The first item is specifically important for mobile apps. Mobile apps have limited bandwidth — at least before 5G — and therefore they rather to have more chatty-oriented conversations with the server. GraphQL allows the client to specifically choose what properties to receive in a very easy way. The heavy lifting to filter is done behind the scene by GraphQL. Figure below shows an example GraphQL query to retrieve each book’s name, and first and last name of the author.

{

book {

name

authors {

firstName,

LastName

}

}

}

This is also very beneficial to backend developers. If you have tried to create REST APIs using ASP.NET, you have probably come across a situation wondering whether you should return sub types or have a separate controller for them. With GraphQL you don’t need to worry about that. You can simply return the entire object graph and let the client filter out what they don’t need.

The second item is something that does not come with ASP.NET templates. Being able to receive real-time updates on changes to data — called graph updates in GraphQL language— requires relying on duplex transport mechanism like SignalR or WebSockets. Anybody who have tried to use these technologies, knows it is not straight forward and easy to use them. GraphQL offers this free of charge using subscriptions. Figure below shows how you can subscribe to an order change:

There are other advantages in using GraphQL like auto-generated API schema and documentation, GraphiQL playground to try APIs that we don’t go through them here.
Hướng dẫn truy vấn dữ liệu blockchain từ Subgraph trên The Graph Network
By: Vinh Le
Tags: The Graph, Web3, The Graph Protocol, GraphQL

Crypto Eager Beaver — I like to read and write.#ICO #cryptocurrency #blockchain
The standard tool is GraphiQL (note the “i” before “QL”) which uses the schema to let you browse…
By: Eric Pascual
Tags: GraphQL

The standard tool is GraphiQL (note the “i” before “QL”) which uses the schema to let you browse the API documentation and also try it interactively.

GraphQL frameworks usually have it embedded and you can expose it with a dedicated route.
022: My Journey to Understand Types in TypeScript, Day 2
By: Joshua Alexander
Tags: Typescript, GraphQL, 100daysofcode

022: My Journey to Understand Types in TypeScript, Day 2

I’m totally cherry-picking the content I’m looking up on TypeScript. It’s neat that TypeScript is code analysis for JavaScript. It’s neat that types are layered over JS to help catch errors and bugs. What I want is to understand types well, and because my primary (and only) coding language is JS, I want to learn to layer types over my code to write cleaner and make better decisions.

However, I don’t want to write code that needs an extra step (or many) in compiling to run. Let types help me in development. As far as my applications are concerned, I’ll only be writing JS. And query languages. For now.

Lean is what I’m working towards.

It was for this purpose that I originally began looking into TypeScript. And also one of the reasons I ended up dropping off learning TypeScript further: I don’t actually want to write TypeScript. However, the whole type system may work to my benefit in writing GraphQL APIs. We shall see.

022/100
018: Introspection and GraphQL APIs
By: Joshua Alexander
Tags: Insomnia, 100daysofcode, GraphQL

This is a continuation of a series following along with my learning journey for GraphQL + Insomnia. Find the source code to follow along with here.

GraphQL

I jumped back into the edX GraphQL training and finished it. In theory, it all sounds very simple. There are some areas that are sorely underdeveloped, though. Resolvers, for one thing, while not entirely nysterious, are still beyond my range of competency. That’s okay though, that will take practice. The course briefly mention introspection, but this was cursory. Given that GraphiQL, the GraphQL Playground, and programs like Insomnia already do this automatically, there really wasn’t much more information to make use of.

One of the biggest shortcomings with introspection, I think, is the ability to determine what will qualify as valid input for a query. Yes, there are types, and they will guide you to some extent, but they won’t help when attempting to interact with a poorly documented public API.

With a resurgence of attention on the tools available in the GraphQL ecosystem, perhaps we will see improved documentation and introspection.

GraphQL content:

Insomnia

I fired up Insomnia as I worked through the training course linked above, to see introspection in action as it was demonstrated. While most API testing and development tools have the capability to extract a schema automatically, it was still cool to see introspection in action. Knowing how this works means you can build apps with vanilla code to understand the schema you’re working with when troubleshooting a problem with your tooling.

I will always be in support of minimizing dependencies wherever possible, and knowing the long way around can go a long way in building apps that rely less on external code.

018/100
REST vs. GraphQL: A Critical Review
By: Aurelian Mesaros
Tags: GraphQL, Graphql Vs Rest, Rest Api, Sofware Development, Rest

- Caching:

- supports application and endpoint caching, but network caching is not supported.

- network caching tools like Varnish, Squid, Fastly, etc. entirely useless

- Facebook has released DataLoader which can make GraphQL client caching easier, but clients not using NodeJS will have to port the logic, or continue to roll their own.

- Does not support versioning, so backward compatibility can be achieved only by:

- creating new APIs.

- implementing a mechanisms that enforces client update to latest version.

- Logic for GraphQL Mutations and Queries goes in the FE.

It means that you may end up with a client architecture that:

- is similar to how a Backend ORM looks(Services, Repositories, Queries).

- has duplicated Queries/Mutations in many components and it's a Hell when you end up having many similar Queries/Mutations present in multiple components.

- To reuse code written for Queries/Mutations you may end up with components that do Over-fetching. For Queries an incomplete solution to alleviate this issue is to use GraphQL Fragments.

- Not the best solution for simple applications.

- Error handling gives you a 200 OK status code. Handled as part of the response body under a special errors object.

- JSON representation only.

- Only a single tool is used predominantly: GraphiQL
GraphQL Server With Java & Clients in Go and Rust
By: Diego Pacheco
Tags: GraphQL, Rust, Java, Microservices, Go

GraphQL it’s an interesting approach for Data Aggregation. GraphQL is a query language API for existing data. You can leverage all your REST APIs and existing data sources. GraphQL it’s mobile-friendly and you can ask literally just the fields you need. GraphQL also allows you to share queries and there are clients for pretty much all languages. GraphQL allows you multiplex and de-multiplex multiple requests in one, being really great for tail latency and nice for data-intensive applications. However, not everything in graphql is flowers and I dont want to paint a rosy picture. There are issues and tradeoffs you need to take into account. I highly recommend you read these 3 series of posts I made comparisons with other approaches like BFs. BFF and GraphQL Dilemma part 1, part 2, and part 3. Today I want to share a video I made where there is a GraphQL Server written in Java and we have 2 clients one Written in Go Lang and the other written in Rust. So Let’s get started.

The video

The Code

GraphQL Server — Written in Java with JDK 15 and Maven 3

GraphQL Client — Written in Go Lang with Machinebox/GraphQL

GraphQL Client — Written in Rust with graphql_client

Cheers,

Diego Pacheco
Why Black People Are On Constant Alert, Always
By: Rebecca Stevens A.
Tags: Equality, Racism, BlackLivesMatter, Society, Black Women

I travel extensively for work and I am always dressed in my Sunday best when I do. My colleagues often wonder why— they sometimes refer to me as a diva who is so full of herself and as such always needs to be styled in the latest fashion.

What they don’t understand is that if I travel in a pair of jeans and a t-shirt, I am sure to get stopped at so-called random security checks, at immigration, and at customs. These experiences leave me emotionally depleted and are always so embarrassing and unpleasant.

There is only so much of this that anyone can take in a given lifetime. So, to avoid all these humiliating experiences, I dress well to travel — night flight or day flight. Dressing well gives me peace of mind.
When White Privilege Shows You White Lives Matter More
By: Rebecca Stevens A.
Tags: White Privilege, Equality, Racism, BlackLivesMatter, Black Women

I, later on, understood that security companies are always instructed to protect the higher-value asset or more senior employee first. Fred was indeed more senior, but the reality is that the security company never provided the full service to me from the start.

My life was not a priority to them — especially when they forgot to pick me up at the airport or didn’t inspect my hotel room. All throughout the trip, they made me feel — more than anyone has ever made me feel, that my black life didn’t matter — at least, not as much as the life of a white man.

I have since recovered from this traumatic event, but it taught me a lesson: to always keep in mind that regardless of what people would like you to believe, our lives are not all valued the same. Whenever I travel to high-risk countries, I carry that extra anxiety with me — what if something were to happen? I have learned to live with this dread, and now simply hope and pray for the best.

Thanks for reading my perspective.
Claiming My Powers Back
By: Nina Mariano
Tags: Notes To Self, Black Women, Self Love

Original: The Power of Bullying

It’s funny to notice the power you can have on your life and the power you can lose when you believe in negative people and racist opinions.

I’m now at street, “wearing” my glorious next-day-afro high up and I feel amazingly beautiful as I never felt (only aside my crying eyes, “The Thirties” never felt so good!) and with only some rímel on as a make up. And people are notably gazing at me in admiration. One guy, when I started this text, was getting some of my-so-known-anxiety-signs looking discretly at me. His body language said “please notice”. I did notice, just wasn’t interested, you already have the clue why.

I know I’m a good professional, I know now I’m beautiful, I know my flaws doesn’t define me.. but some situations still get me. Even if I don’t want to think about it, it’s unpredictable. Sometimes someone says something and I ignore and move on, sometimes I curse back, sometimes it keeps bugging me for days, months, years… decades.

As a diasporic person in Brazil, it’s clear for me now how unhealthy it is for a black woman to try to fit in a white society. We straighten our hair, we clear our photos, we accept to demonize and criticize our beautiful culture as they expect us to do. We accept words of depreciation about our skin, our bodies, our looks, our intelligence, to look more like everyone and end up still miserable without knowing why.

My cycle of self hate ends here. I can’t take denying myself to be one of them anymore. I’m not one of them, I’m extraordinarily me now. All the pain I felt will now be my gas to feel happier, more lovable, more beautiful than always. I shall be open to people interactions and stop living in the past after this text. So I believe, so it’ll be.

I’m ready to be happy now.

São Paulo, Brazil. March 12, 2020.

********

Reading in December 2020 and seeing how powerful that words are to me now. There’s more from where that came.
Your New Favorite Book: “Cinderella is Dead”
By: Zoe Bryant
Tags: LGBTQ, Youngadult, Lesbian, Books, Black Women

This debut dystopian novel by Kalynn Bayron examines how fairy tales impact the way we grow up in a much more literal sense: our main character lives under an oppressive regime first created by Prince Charming in the universe of Cinderella. It has been 200 years since Cinderella’s death, and the young women of Lille are forced to attend a ball for their king. If they are not chosen to be a wife of aristocracy within their first three balls, they are never heard of again.

In this world where women face marriage or presumed death, Sophia Grimmins is in love with another girl from her town. To Sophia, marriage is the worst fate she could suffer; lesbianism aside, the majority of men in her town were downright abusive to their wives. The three kings succeeding Prince Charming were equally oppressive with their laws against women, slowly turning the town of Lille into a tyrannical totalitarian society where men had all the power. Sophia vows to run away rather than attend the king’s ball, leading her on an adventure that teaches her the true history of Cinderella that generations before her had erased in favor of the fairy tale we know and love today.

“Cinderella is Dead” does an amazing job exploring the impact of brainwashing on a society, including how humans can be conditioned to be as tolerant or intolerant as our leaders see fit. With anything other than heterosexuality and submission to the kingdom banned, “Cinderella is Dead” shows the perspectives of various outcasts, from the homosexual man Sophia befriends to the exiled descendant of evil step-sister Gabrielle, and how these outcasts fit into King Manford’s natural order.

— Spoiler Beginning —

My only genuine criticism with this book is the lack of a conclusive ending. I will say the plot is wrapped up nicely, however there is some character work lacking. The ending does not mention what comes of Erin or Luke, the two most prominent side characters. The lack of closure between Sophia, Erin and Constance is slightly unsettling for the reader, who wants to know how the characters reconcile their slight love triangle. This criticism is immensely small, as our book is clearly a hero’s individual journey before a romance.

— Spoiler Ending —

I would rate “Cinderella is Dead” by Kelynn Bayron five stars, for a satisfying wrap to Sophia Grimmens’s story, and creativity unlike I’ve seen before that so nicely combined the fantasy, dystopian, contemporary and romance genres.
Attention All Up & Coming African-American / Black Artists, Poets, Writers & Creatives
By: M. Campbell
Tags: African Literature, Black Panther, BlackLivesMatter, Black Women, African American

Art Lover, Poet, Author, Blogger. ♦Talent, if you don’t use it, what is it good for? http://maryannesbookshelf.com
Attention All Up & Coming African-American / Black Artists, Poets, Writers & Creatives
By: M. Campbell
Tags: African Literature, Black Writers, BlackLivesMatter, Black Women, African American

Your artistic contributions are wanted for a Black Love Anthology book. Add to your portfolio, or curriculum vitae, give back to and celebrate your community and rich heritage and culture, make a statement, be heard and inspire…
Magical Beauty
By: Melanie J.
Tags: Poetry On Medium, Haiku, Poetry, A Few Words, Black Women

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
For Imperfect Daughters
By: Yemisi Fadiya
Tags: Women, Poetry On Medium, Poetry, Daughters, Black Women

Photo by Obi Onyeador on Unsplash

For imperfect daughters

who peel their skin waiting on validation

from men who leave them gasping for air

drowning in an abyss of longing

For imperfect daughters

who has died deaths of rejection

seeking resurrection in the faces of men

who know nothing about living

For imperfect daughters

with gaping voids of abandonment

who bury themselves in yesterdays grief

blinded to tomorrows joy

I write to you

I write to tell you

even gardens with weeds

still grow roses
Before And After: Christmas Shopping While Black
By: Rebecca Stevens A.
Tags: Christmas, Equality, Racism, BlackLivesMatter, Black Women

Christmas shopping is meant to be fun right? Especially this year since one has to queue up for hours to get into stores due to the pandemic. Well, for me a black woman, Christmas shopping proved to be yet another painful experience. Mind you, I did a lot of my shopping online just to remove the pain of a racist encounter, but, yesterday, I realized there were a few gifts missing so off to the stores I went.

After a relatively long time queuing outside, I was let into an Ali Baba’s cave of hundreds of potential gifts to buy. I walked around evaluating my options, asking myself if such and such a person would appreciate this or that gift. I paused at the Dyson vacuum cleaner display, fascinated by a video showing the tornado-like aspiration power of these colorful high tech brooms. A sales lady came up to me:

“How can I help you?”

I had no intention of buying one of these highly-priced objects and didn’t want her to waste her time trying to convince me.

“Oh I’m just browsing, I don’t need any help”, I responded politely.

The sales lady still stood there.

“So this is how it works, ” she insisted, removing one of the vacuum cleaners from the display.

“Thanks, Madame, I’m not looking to buy …..”

“Why can’t you people be damn appreciative”, she blurted out.

I looked at her, my face registering an uneasy surprise.

“I don’t need a vacuum cleaner”, I insisted politely.

“So why are you looking here? Even if you did want one, I don’t have any in stock anyway, and I’m sure that if I did, you couldn’t afford it”, she said furiously before stomping off.