Logo

dev-resources.site

for different kinds of informations.

HTTP and GraphQL

Published at
12/12/2024
Categories
graphql
nosql
http
tutorial
Author
junissen
Categories
4 categories in total
graphql
open
nosql
open
http
open
tutorial
open
Author
8 person written this
junissen
open
HTTP and GraphQL

Returning to data transport (and to life, because data needs to be sent between systems), I will say that HTTP perfectly reproduces its functions adjacent to the database.

The classic HTTP method contains:

  1. URL of the place we are accessing
  2. Method Header
  3. Method type (POST, GET, DELETE, PUT)
  4. The body of the request, where the essence of the data is located

There are a couple more HTTP methods, but you don't use the whole table service when you're having dinner, do you? Just a fork, spoon, knife, plate. No more!

function toRequest(
  req: FastifyRequest,
  reply: FastifyReply,
): RawRequest<FastifyRequest, RequestContext> {
  return {
    url: req.url,
    method: req.method,
    headers: req.headers,
    body: req.body as any,
    raw: req,
    context: { reply },
  };
}
Enter fullscreen mode Exit fullscreen mode

In fact, you are familiar with the body method parameter, because it is the JSON I have already described. This is the most convenient structure for using this data section.

export async function parseRequestParams(
  req: FastifyRequest,
  reply: FastifyReply,
): Promise<RequestParams | null> {
  const rawReq = toRequest(req, reply);
  const paramsOrRes = await rawParseRequestParams(rawReq);
  if (!('query' in paramsOrRes)) {
    const [body, init] = paramsOrRes;
    reply
      .status(init.status)
      .headers(init.headers || {})
      .send(body || undefined);
    return null;
  }
  return paramsOrRes;
}
Enter fullscreen mode Exit fullscreen mode

The async function characterizes our type of calls as asynchronous, i.e. no one will stand in line while our server works. Any client will leave a request and return to their business, the answer will come automatically.

These are just the helper parameters and functionality that GraphQL offers to create your own HTTP channel with methods and calls! A more complete description of HTTP can be found on GitHub/created yourself as a training exercise in forwarding calls between systems.

nosql Article's
30 articles in total
Favicon
O que é o Apache Cassandra e quando usar?
Favicon
Efficient Batch Writing to DynamoDB with Python: A Step-by-Step Guide
Favicon
SQL VS NoSQL
Favicon
MongoDB: How to setup replica sets
Favicon
Do you think schema flexibility justifies using NoSQL? Think twice.
Favicon
Series de tiempo en MongoDB
Favicon
What I Learned from the 'Amazon DynamoDB for Serverless Architectures' Course on AWS Skill Builder
Favicon
MongoDB Command Shortcuts: The Ultimate Guide
Favicon
MongoDB: Startup replica sets with a config file
Favicon
Azure Logs Analytics for CosmosDB
Favicon
Choosing the Right Database: A Simplified Guide
Favicon
Understanding the Differences Between NoSQL and SQL Databases
Favicon
Part 2 - CosmosDB Logical Partition and the Impact on Partition Key Choice
Favicon
Partitions in Azure Cosmos DB: A Common Discussion with Customers
Favicon
Database Sharding: Simplifying Data Scalability
Favicon
HTTP and GraphQL
Favicon
New possibilities with GraphQL
Favicon
NoSQL delivers quick value
Favicon
Navigating Databases: From SQL to NoSQL
Favicon
Selecting the Right Database for the Job
Favicon
NewSQL: Bridging the Gap Between SQL and NoSQL
Favicon
Weekly Updates - October 18, 2024
Favicon
Overcoming MongoDB Limitations with Fauna
Favicon
MongoDB Developer Day Manila 2024: A Recap - A Deep Dive into the Future of Data
Favicon
How to choose the right database?
Favicon
SQL vs. NoSQL: Key Differences, Use Cases, and Choosing the Right Database for Your Project
Favicon
Top 5 SQL questions asked in interviews
Favicon
Weekly Updates - Nov 8, 2024
Favicon
Plain Javascript Refresher for those feeling left behind or not knowing where to start w/ Functions, Arrays, Loops, JSON & NoSQL
Favicon
Mastering DynamoDB: Batch Operations Explained

Featured ones: