🧪 Master testing once and for all. Get a 25% off discount on my new Testing Mastery course. Ends in 2 days.
Most devs struggle with testing! Learning how to write useful tests (on any side of the stack), is without a doubt, the first skill every developer can master to get on track with what actually matters, and propel yourself forward to take on 10x more difficult problems.
Today, I'm proud to announce the launch of "Testing Mastery": The Software Essentialist Bachelors Program, where you'll learn and practice writing powerful tests on any side of the stack, starting from first principles.
Before the end of the month (October 31st), you can get the entire suite of courses in the program for 25% off using the discount code TESTING-MASTERY. Enroll here.
Because despite what it seems like, you don't have to burn out trying to keep up with all the latest JavaScript libraries and frameworks. You don't have to learn everything. You just have to master what matters.
All the best, and as always, To Mastery!
Deploying Serverless GraphQL APIs with TypeScript on Netlify
Deploying a Serverless GraphQL API with TypeScript is essentially the same as deploying one with JavaScript.
The only difference is in the build steps.
For example, using vanilla JavaScript on Netlify, the build step in our package.json
is usually to copy all of the vanilla JavaScript code in our src
folder over to the functions
folder.
{
"scripts": {
"start": "nodemon",
"bundle": "cpx src/**/* functions/bundle" }
}
While building with TypeScript is effectively the same, just through different means. In a TypeScript environment, we configure a tsconfig.json
and run tsc
as the build step.
{
"compilerOptions": {
"allowJs": true,
"module": "commonjs",
"moduleResolution": "node",
"pretty": true,
"sourceMap": true,
"target": "es2017",
"outDir": "./functions/bundle", "lib": ["es6"],
"resolveJsonModule": true,
"types": ["node"],
"typeRoots" : ["./node_modules/@types", "./src/@types"],
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"esModuleInterop": true
},
"include": [
"src/*.ts",
"src/**/*.ts",
"src/**/*.js"
],
"exclude": [
"node_modules",
"src/**/*.spec.ts",
"src/**/*.spec.js"
]
}
{
"scripts": {
"start": "nodemon",
"bundle": "tsc" }
}
Either way, the result is the same since Netlify needs all of the source code used in the functions
direction to be bundled before it's deployed.
Resources
Check out these starters for deploying your own Serverless GraphQL APIs on Netlify with TypeScript or vanilla JavaScript.
Starters
- Serverless GraphQL on Netlify API Starter Project
- Serverless GraphQL on Netlify API using TypeScript Starter Project
Tutorial
If you're interested in how the starters were built, read "How to Deploy a Serverless GraphQL API on Netlify [Starters]".
Discussion
Liked this? Sing it loud and proud 👨🎤.
🧪 Master testing once and for all. Get a 25% off discount on my new Testing Mastery course. Ends in 2 days.
Most devs struggle with testing! Learning how to write useful tests (on any side of the stack), is without a doubt, the first skill every developer can master to get on track with what actually matters, and propel yourself forward to take on 10x more difficult problems.
Today, I'm proud to announce the launch of "Testing Mastery": The Software Essentialist Bachelors Program, where you'll learn and practice writing powerful tests on any side of the stack, starting from first principles.
Before the end of the month (October 31st), you can get the entire suite of courses in the program for 25% off using the discount code TESTING-MASTERY. Enroll here.
Because despite what it seems like, you don't have to burn out trying to keep up with all the latest JavaScript libraries and frameworks. You don't have to learn everything. You just have to master what matters.
All the best, and as always, To Mastery!
Stay in touch!
Join 15000+ value-creating Software Essentialists getting actionable advice on how to master what matters each week. 🖖
View more in GraphQL
You may also enjoy...
A few more related articles