Showing posts with label Server. Show all posts
Showing posts with label Server. Show all posts

Sunday 28 March 2021

Graphql basic example with code snippet

Graphql basic example with code snippet
Question: What is GraphQL?
GraphQL is a query language for API, and it is server-side runtime for executing queries by using a type system you define in server.


Question: What is GraphQL used for?
Load data from a server to a client (API)


Is GraphQL a REST API?
GraphQL follows the same set of constraints as REST APIs, but it organizes data into a graph. GraphQL can speed up development and automation in comparison to REST API.


Is GraphQL frontend or backend?
Its neither frontend or backend. Its language to exchange the data between client and server.


Does Facebook use GraphQL?
Facebook used GraphQL since 2012.


Who uses GraphQL?
Facebook. Instagram. Shopify. Twitter. StackShare. Stack. The New York Times. Tokopedia. etc


GraphQL Example 1 with Node
var { graphql, buildSchema } = require('graphql');

var schema = buildSchema(`
  type Query {
    name: String,
    age: String,
  }
`);

var root = { name: () => 'My Name is Arun kumar.', age: ()=> '20 Year' };

graphql(schema, '{name}', root).then((response) => {
  console.log(response);
});



GraphQL Example 2 with Node
var { graphql, buildSchema } = require('graphql');

var schema = buildSchema(`
  type Query {
    name: String,
    age: String,
  }
`);

var root = { name: () => 'My Name is Arun kumar.', age: ()=> '20 Year' };

graphql(schema, '{name,age}', root).then((response) => {
  console.log(response);
});



GraphQL Example 3 with Node
var { graphql, buildSchema } = require('graphql');

var schema = buildSchema(`
  type Query {
    name: String,
    age: String,
    address: String,
  }
`);

var root = { name: () => 'My Name is Arun kumar.', age: ()=> '20 Year', address: ()=>'#238, Palm city, Sector 127, kharar'};

graphql(schema, '{name,age,address}', root).then((response) => {
  console.log(response);
});



GraphQL Example 4 with Node
const express = require('express');
const { ApolloServer, gql } = require('apollo-server-express');

const typeDefs = gql`
  type Query {
    hello: String,
    name: String,
    age: String,
    address: String,
    city: String,
  }
`;


const resolvers = {
  Query: {
    hello: () => 'Hello world!',
    name: () => 'My Name is Arun kumar.',
    age: ()=> '20 Year',
    address: ()=>' Sector 127, mohali',
    city:()=> 'kharar'
  },
};

const server = new ApolloServer({ typeDefs, resolvers });

const app = express();
server.applyMiddleware({ app });

app.listen({ port: 4000 }, () =>
  console.log('Now browse to http://localhost:4000' + server.graphqlPath)
);




GraphQL Example 5 with Node
var express = require('express');
var { graphqlHTTP } = require('express-graphql');
var { buildSchema } = require('graphql');

var schema = buildSchema(`
  type Query {
    hello: String,
    name: String,
    age: String,
    address: String,
    city: String,
  }
`);

var root = {
  hello: () => 'Hello world!',
  name: () => 'My Name is Arun kumar.',
  age: ()=> '20 Year',
  address: ()=>' My city, Sector 127',
  city:()=> 'kharar'
};

var app = express();
app.use('/graphql', graphqlHTTP({
  schema: schema,
  rootValue: root,
  graphiql: true,
}));
app.listen(4000, () => console.log('Now browse to localhost:4000/graphql'))





Monday 31 July 2017

Server Architecture Interview Questions and Answer

Server Architecture Interview Questions and Answer

Question: What is VPC?
Full form of VPC is Virtual Private Cloud.
It is virtual network dedicated to AWS account.It is logically isolated to the other virtual network in the AWS cloud.


Question: Can a VPC of any size be created?
Yes, After selecting an option, you can modify the size and IP address range of the VPC and its subnets.
You can modify the VPC to add more subnets or add/remove gateways at any time after the VPC has been created.
Question: How do AWS VPC work?
It is logically isolated from other virtual networks. You can launch your AWS resources, such as Amazon EC2 instances, into your VPC.
You can configure your VPC and select its IP address range, create subnets, and configure route tables, network gateways, and security settings.

Question: What is route table in AWS?
A route table contains a set of rules, that are used to determine where network traffic is directed.
Each subnet in your VPC must be associated with a route table, the route table controls the routing for the subnet.


Question: What is an Internet gateway AWS?
An Internet gateway is a horizontally scaled, redundant, and highly available VPC component that allows communication between instances in your VPC and the Internet.


Question: What is an Amazon VPC?
Amazon VPC lets you provision a logically isolated section of the Amazon Web Services (AWS) cloud where you can launch AWS resources in a virtual network that you define.

Following are components of VPC
  1. A Virtual Private Cloud
  2. Subnet
  3. Internet Gateway
  4. NAT Gateway
  5. Hardware VPN Connection
  6. Virtual Private Gateway
  7. Customer Gateway
  8. Router



Question: What is an Elastic IP address?
An Elastic IP address is a static IPv4 address designed for dynamic cloud computing. With an Elastic IP address, you can mask the failure of an instance or software by rapidly remapping the address to another instance in your account.
Question: What is AWS VPN?
You can connect your VPC to remote networks by using a VPN connection.


Question: What is Route 53?
Amazon Route 53 (Route 53) is a scalable and highly available Domain Name System (DNS).


Question: What is a static route?
Static routing is a form of routing that occurs when a router uses a manually-configured routing entry, rather than information from a dynamic routing traffic.


Question: What do you mean by dynamic routing?
Dynamic routing is a networking technique that provides optimal data routing. dynamic routing enables routers to select paths according to real-time logical network layout changes.


Question: What is meant by API gateway?
The API Gateway will often handle a request by invoking multiple microservices and aggregating the results.
It can translate between web HTTP and WebSocket and web?unfriendly protocols that are used internally.


Question: What is an API management?
It is process of publishing, documenting and overseeing application programming interfaces (APIs) in a secure, scalable environment.


Question: What is Amazon MWS?
Full form of MWS is Amazon Marketplace Web Service. It is an integrated web service API that helps Amazon sellers to programmatically exchange data on listings, orders, payments, reports, and more. Data integration with Amazon enables high levels of selling automation, which can help sellers grow their business.


Question: What is cloud computing?
cloud computing is the delivery of computing services—servers, storage, databases, networking, software, analytics and more—over the Internet.


Question: what is load balancer?
A load balancer is a device that acts as a reverse proxy and distributes network or application traffic across a number of. servers.
Load balancers are used to increase capacity (concurrent users) and reliability of applications.


Question: What is load balancing on a router?
Network load balancing is the ability to balance traffic across two WAN links without using complex routing protocols like BGP.


Question: How do load balancing servers work?
A load balancer acts as the "traffic cop" sitting in front of your servers and routing client requests across all servers capable of fulfilling those requests in a manner that maximizes speed and capacity utilization and ensures that no one server is overworked.


Question: What is Lambda?
AWS Lambda lets you run code without managing servers, AWS states on the Lambda product page.
You can think of Lambda as an event-driven computing platform;
Lambda runs when triggered by an event and executes code that's been loaded into the system.


Friday 6 February 2015

How to delete MySQL Binary logs Files in Wamp Server?

How to delete MySQL Binary logs Files in Wamp Server?



Sometime we find our Wamp Server is talking too much space like 10GB whereas it must take less than the current size. It may be your mysql binary log files are taking too much space in data.
Binary files look like below:
mysql-bin.000001,
mysql-bin.000002,
................,
mysql-bin.000221

Before we delete the mysql binary log files permanently, we should know about these binary log files like what type of files are these and how effect our server.


Question: What is Mysql Binary logs file?
MySQL binary logs are the text file, created by mysql automatically. Default files name are "mysql-bin.000001" which located in data folder of mysqlx.x.


Question: What is purpose of Binary logs file?
It has two purpose
Data Recovery: It is used for data recovery operations.
High availability / replication: It is used on master replication servers as a record of the statements to be sent to slave servers.


Question: What is default location of binary log file?
E:\wamp\bin\mysql\mysql.x.x\data


Question: How can change the Binary log file name?
Open my.ini file under mysql.x.x folder.
In my window system:
E:\wamp\bin\mysql\mysql.x.x\my.ini


Question: Update the following "mysql-bin" name
log-bin=mysql-bin


Question: How to disable the automatic creating binary log files?
Open my.ini file under mysql.x.x folder.
In my window system: E:\wamp\bin\mysql\mysql.x.x\my.ini
Search
log-bin=mysql-bin
and replace with following
#log-bin=mysql-bin



Question: What is dis-advantage of mysql binary log files?
Its takes too much space, some times it take upto 10MB or more space.


Question: How to delete mysql bin files permanently?
It have 3 steps and are following.

Step 1: Disable automatic creating file.
open my.ini file under mysql.x.x folder.
Search
log-bin=mysql-bin
and Replace with following
#log-bin=mysql-bin

Step 2:
Restart Wamp Server

Step3 :
Now you can delete all files start with "mysql-bin.0000xx"

Never delete mysql bin files directly you must follow Step 1






Tuesday 3 February 2015

How to add DNS Record In GoDaddy?

How to add DNS Record In GoDaddy?

What is DNS Record?
DNS stands for Domain Name System, It is digital database which contains the information about every live web site. Every website has Website Name and IP Address.

IP Address is location of the website which is used to locate the web site within the DNS database.

DNS records are basically mapping files that tell the DNS server which IP address each domain is associated and how to handle the request for each domain.


Following are different types of Record type in DNS
CNAME record stands for canonical name and serves to make one domain an alias of another domain. It is associate with sub-domains with an existing domain's DNS records.
PTR record stands for pointer record and maps an Ipv4 address to the CNAME on the host.
MX record stands for mail exchange and is basically a list of mail exchange servers.
NS record stands for name server and indicates which Name Server is authoritative for the domain.
SOA record stands for State of Authority. It stores important information like when the domain was last updated.
SRV record stands for service and is used to define a TCP service.
TXT record lets the administrator insert any text they'd like into the DNS record.



How to Edit DNS from "DNS Manager" in GoDaddy.
1. Open https://godaddy.com/
2. Login / Sign In with your Go Daddy account
3. After login, you will see following page

4. Now click on Launch (If you have multiple domain then you can select "launch" of that particular domain).
5. When you click on Launch, you will see following page


6. From top header, select DNS=>DNS Manager, you will see following page


7. Now Click on Edit Zone as in above Screen.
8. Now you will see following page, It is Zone File Editor.  Here you can add one or more DNS entry.


9
. Now Click on Add Record.
10. A page will open. Now  Select "Txt" from Record Type, you will see following page


11. Now Add values in "TXT Name" and "TXT Value" and Click on "OK"
12. You can add one or more records, Its reflection may take 01 Hour or more.