Search⌘ K
AI Features

Updating our Schema

Explore how to update a GraphQL schema by adding User types, defining queries like getUser, and creating mutations such as addUser, all integrated with PostgreSQL in a Deno application. Understand how to connect to a Postgres database, define resolvers, and test the endpoint to manage user data effectively.

User type and input

We’ll use a schema with only the User type. Let’s start by adding this type and then creating our resolvers. We’ll add the definition of the following types:

TypeScript 3.3.4
const types = gql`
type User {
id: String
firstname: String
lastname: String
}
input UserInput {
firstname: String
lastname: String
}
`;

User queries

In this section, we’ll define our queries. In particular, we’ll define the getUser query that returns a given user from their associated id. As the first step, let’s add the query to our types:

...