TypeScript implementation of Twitter clone originally by Tyler McGinnis with FaunaDB powered GraphQL backend. Live demo
- GraphQL backend using FaunaDB and called using Netlify Functions (lambda/serverless).
- Remove tweet functionality for authenticated user.
- TypeScript
- FaunaDB + GraphQL
- Netlify Functions (Serverless/Lambda functions)
- Apollo
- GraphQL Code Generator
- React + Redux
- Create React App
Available at https://ui-twitter-ts.zweisolutions.com/
- Run
npm install
in the main directory (package.json should be accurate)- Special Notes:
- Source/Dev:
src
folder - Production:
build
folder - Functions:
functions
folder - Compiled functions:
build-functions
folder
- Source/Dev:
- Special Notes:
- Link the local development environment to a Netlify site. Enable the FaunaDB addon. Create a new database in Fauna.
- Run
npm run bootstrap
to upload themasterSchema.gql
file in thescripts
folder to Fauna (which will autogenerate a lot of GraphQL schema as well). This will then also upload some sample data to your new database. - Run one of the commands from the Scripts section. You'll most likely want
npm run dev
for development andnpm run build
for production.
npm run dev
: Create development build and serve it on dev servernpm run build
: Build application for production (build directory: build)npm run start
: Start app without netlify development server. Will likely fail.npm run startWithoutMerge
: Same as above without merging the masterSchema file.npm run eject
: See documentation herenpm run functionsBuild
: Will runnetlify-lambda
and build the TypeScript functions into thebuild-functions
folder.npm run codegen
: Will generate GraphQL TypeScript bindings.npm run codegenWatch
: Same as above in watch mode.npm run mergeSchema
: Will merge the masterSchema file into Fauna.npm run bootstrap
: Will merge the masterSchema and upload sample data.
- Combine initial data fetch calls into one call
- Implement authentication when Fauna implements GraphQL native bindings for it (can accomplish using resolvers in the meantime but out of the scope of this project)
- Using
@graphql-codegen/typescript-document-nodes
plugin for GraphQL Code Generator to allow easy importation of GraphQL AST code when bundling functions usingnetlify-lambda
. - Function endpoints:
getTweets
: Will get tweets and convert to a Tweets type.getUsers
: Will get users and convert to a Users type.removeTweet
: Will remove tweet and update tweets it was replying to.saveLikeToggle
: Will toggle like status on tweet.saveTweet
: Will create a new Tweet with provided data.
- Authed user is set in
src/actions/shared
to Tyler McGinnis. - When implementing proper user authentication in the future, care should be taken to check user authentication on the server side.
- Babel configuration and
functions/shared/webpack.config.js
files are used purely for functions and not for client facing code. - No GraphQL caching is enabled since the Apollo calls are on the backend serverless functions.
- Users are identified by Fauna ID rather than by the original strings.
- Netlify functions sometimes provide cached results. This shouldn't affect the app until the user reloads as it maintains a client side state. Cache invalidation headers were set but each node in the Netlify CDN may take time to use them or use them with differing results.
I'm available for freelance, contracts, and consulting both remotely and in the Hudson Valley, NY (USA) area. Some more about me and what I can do for you.
Feel free to drop me a message at:
hi [a+] zweisolutions {โ} com