Skip to content

Instantly share code, notes, and snippets.

View oxlb's full-sized avatar
🎯
Focusing

Onexlab (Munish Kapoor) oxlb

🎯
Focusing
View GitHub Profile
const server = new ApolloServer({
typeDefs,
resolvers,
csrfPrevention: true,
});
// The `listen` method launches a web server.
server.listen().then(({ url }) => {
console.log(`🚀 Server ready at ${url}`);
});
const resolvers = {
Query: {
students: async() => await getStudents(),
}
};
async function getStudents() {
const result = await knex.select().from('student');
return result;
}
/*
You can uncomment line 6 to 12 to test the database connectivity
(async() => {
const students = await getStudents();
console.log(students);
const { knex } = require('./connection');
const { ApolloServer, gql } = require('apollo-server');
const typeDefs = gql`
type Student {
id: ID!
name: String!
}
type Query {
const { knex } = require('./connection');
const { ApolloServer, gql } = require('apollo-server');
const typeDefs = gql`
type Student {
id: ID!
name: String!
}
type Query {
const knex = require('knex')({
client: 'mysql',
connection: {
host : '192.168.1.106',
port : 3306,
user : 'user',
password : 'user',
database : 'mydb'
}
});
CREATE TABLE student (
id int NOT NULL AUTO_INCREMENT,
name VARCHAR (255),
PRIMARY KEY (ID)
);
INSERT INTO student(id, name) VALUES
(1, 'A'),
(2, 'B'),
(3, 'C');
@oxlb
oxlb / main.tf
Last active March 21, 2022 05:25
provider "aws" {
region = "us-east-1"
access_key = "test123"
secret_key = "testabc"
skip_credentials_validation = true
skip_requesting_account_id = true
skip_metadata_api_check = true
endpoints {
sns = "http://localhost:4566"
}
version: '3.0'
services:
localstack:
image: localstack/localstack:latest
environment:
- AWS_DEFAULT_REGION=us-east-1
- EDGE_PORT=4566
- SERVICES=sns
ports:
@oxlb
oxlb / main.tf
Created February 24, 2022 05:39
provider "aws" {
region = "us-east-1"
access_key = "test123"
secret_key = "testabc"
skip_credentials_validation = true
skip_requesting_account_id = true
skip_metadata_api_check = true
endpoints {
sqs = "http://localhost:4566"
}