This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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}`); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const resolvers = { | |
| Query: { | |
| students: async() => await getStudents(), | |
| } | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { knex } = require('./connection'); | |
| const { ApolloServer, gql } = require('apollo-server'); | |
| const typeDefs = gql` | |
| type Student { | |
| id: ID! | |
| name: String! | |
| } | |
| type Query { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { knex } = require('./connection'); | |
| const { ApolloServer, gql } = require('apollo-server'); | |
| const typeDefs = gql` | |
| type Student { | |
| id: ID! | |
| name: String! | |
| } | |
| type Query { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const knex = require('knex')({ | |
| client: 'mysql', | |
| connection: { | |
| host : '192.168.1.106', | |
| port : 3306, | |
| user : 'user', | |
| password : 'user', | |
| database : 'mydb' | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: '3.0' | |
| services: | |
| localstack: | |
| image: localstack/localstack:latest | |
| environment: | |
| - AWS_DEFAULT_REGION=us-east-1 | |
| - EDGE_PORT=4566 | |
| - SERVICES=sns | |
| ports: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | |
| } |
NewerOlder