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
{ | |
"scripts": { | |
"build": "tsc -p tsconfig.json", | |
"build:watch": "tsc -w -p tsconfig.json", | |
"start:dev": "NODE_ENV=development nodemon build/server.js", | |
"start:prod": "NODE_ENV=production nodemon build/server.js", | |
"start:production": "concurrently \"yarn build:watch\" \"yarn start:prod\"", | |
"start": "concurrently \"yarn build:watch\" \"yarn start:dev\"", | |
}, | |
} |
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
overwrite: true | |
schema: "http://localhost:5000/graphql" | |
documents: null | |
generates: | |
src/generated/graphql.ts: | |
plugins: | |
- "typescript" | |
- "typescript-resolvers" | |
config: | |
useIndexSignature: true |
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
{ | |
[...] | |
"scripts": { | |
[...] | |
"codegen": "graphql-codegen --config codegen.yml" | |
}, | |
[...] | |
} |
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
import * as mongoose from 'mongoose'; | |
function timestamp() { | |
return +new Date(); | |
} | |
export interface MessageDocument extends mongoose.Document { | |
sender_id: string; | |
senderName: string; | |
text: string; |
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
import { gql } from 'apollo-server-express'; | |
import { PubSub } from 'apollo-server'; | |
import { QueryResolvers, MessagesMutationResolvers } from '../generated/graphql'; | |
import MessageModel from '../models/MessageModel'; | |
const NEW_MESSAGE_EVENT = 'NEW_MESSAGE'; | |
const pubsub = new PubSub(); | |
const typeDefs = gql` |
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
import { SchemaDirectiveVisitor } from 'graphql-tools'; | |
import { gql, AuthenticationError } from 'apollo-server'; | |
import { GraphQLField, defaultFieldResolver } from 'graphql'; | |
import AccessTokenModel from '../models/AccessTokenModel'; | |
import { ResolverContext } from '../types'; | |
class AuthDirective extends SchemaDirectiveVisitor { | |
visitFieldDefinition(field: GraphQLField<any, any>) { | |
const { resolve = defaultFieldResolver } = field; |
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
import { StackNavigationProp } from '@react-navigation/stack'; | |
import { RouteProp } from '@react-navigation/native'; | |
export type AuthStackParams = { | |
Login: undefined; | |
}; | |
export type AuthNavProps<T extends keyof AuthStackParams> = { | |
navigation: StackNavigationProp<AuthStackParams, T>; | |
route: RouteProp<AuthStackParams, T>; |
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
import { StackNavigationProp } from '@react-navigation/stack'; | |
import { RouteProp } from '@react-navigation/native'; | |
export type MainStackParams = { | |
Conversation: undefined; | |
}; | |
export type MainNavProps<T extends keyof MainStackParams> = { | |
navigation: StackNavigationProp<MainStackParams, T>; | |
route: RouteProp<MainStackParams, T>; |
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
import React from 'react'; | |
import { createStackNavigator } from '@react-navigation/stack'; | |
import { AuthStackParams } from './types/AuthStackParams'; | |
import { LoginScreen } from '../screens/LoginScreen'; | |
const AuthStack = createStackNavigator<AuthStackParams>(); | |
export const AuthStackScreens: React.FC = () => ( | |
<AuthStack.Navigator initialRouteName="Login"> | |
<AuthStack.Screen |
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
import React from 'react'; | |
import { createStackNavigator } from '@react-navigation/stack'; | |
import { MainStackParams } from './types/MainStackParams'; | |
import { ConversationScreen } from '../screens/ConversationScreen'; | |
const MainStack = createStackNavigator<MainStackParams>(); | |
export const MainStackScreens: React.FC = () => ( | |
<MainStack.Navigator | |
initialRouteName="Conversation" |