Welcome to Part 2 of our GraphQL tutorial series on TeachMeJS. In Part 1, we set up a simple GraphQL server using Node.js and Apollo Server. If you haven’t followed that post yet, go check it out first here.
In this post, we’ll dive deep into the GraphQL schema — the heart of every GraphQL API. You’ll learn how to define:
Object types (with the type keyword)
Query and Mutation types
The difference between Scalars and Custom Types
And best of all, we’ll walk through the whole process using Visual Studio Code (VS Code) — so you know exactly where to write your code and how to run it.
📁 Project Folder Structure in VS Code
Before we dive into the code, here’s how your folder structure should look in VS Code:
Here,
/graphql-server │ ├── index.js ← Main server entry point ├── schema.js ← where you define GraphQL types and schema ├── resolvers.js ← where your query/mutation logic goes ├── package.json
Step 1: Setup (If Not Done Yet)
⛳ If you’ve already completed Part 1, skip this section.
Open VS Code and run the following in the terminal: