Skip to content

Instantly share code, notes, and snippets.

View AyoubEd-zz's full-sized avatar
⛩️
Mudblood and proud

AyoubED AyoubEd-zz

⛩️
Mudblood and proud
View GitHub Profile
service:
name: aws-typescript-graphql-tuto
# Add the serverless-webpack plugin
plugins:
- serverless-webpack
- serverless-offline
provider:
name: aws
import { ApolloServer, gql } from 'apollo-server-lambda';
import { CommentService } from './comment.service';
const typeDefs = gql`
type Comment{
msgId: Int
userId : String
content : String
createdAt : String
deleted : Boolean
export interface Comment {
msgId: number,
userId: string,
content: string,
createdAt: number,
deleted: Boolean
}
import { Comment } from './types';
import { ICommentStorage, CommentStorage } from './comment.storage';
export interface ICommentService {
getComments(itemId: string): Promise<[Comment]>;
addComments(itemId: string, userId: string, content: string): Promise<[Comment]>;
editComments(itemId: string, msgId: number, userId: string, content: string): Promise<[Comment]>;
deleteComments(itemId: string, msgId: number, userId: string): Promise<[Comment]>;
import * as redis from 'redis'
import { promisify } from 'util';
import { Comment } from './types'
const redisOptions = {
host: process.env.redisHost,
port: process.env.redisPort,
}
let client;
import { ApolloServer, gql } from 'apollo-server-lambda';
const typeDefs = gql`
type Query {
hello: String
}
`;
const resolvers = {
Query : {
  serverless config credentials --provider aws --key YOUR_ACCESS_KEY --secret YOUR_SECRET_KEY
# Installing the serverless cli
npm install -g serverless
# Updating serverless from a previous version of serverless
npm install -g serverless
# Login to the serverless platform (optional)
serverless login