Using Apollo with TypeORM
After we've created the entities and inserted some test data, we'll look at how to integrate Apollo with TypeORM. In this section, we'll define our GraphQL resolvers, which are functions that will be called when we send queries and mutations to our GraphQL endpoint:
- First, you need to change back the
user
andauthor
fields on thePost
,Comment
, andLike
types of our GraphQL schema, in thesrc/graphql/schema.graphql
file, to the type ofUser
instead ofID
:author: User! user: User!
- Additionally, change the type of the
post
field fromID
toPost
in theComment
andLike
types:post: Post!
Before implementing our schema resolvers, we need to create the types for ensuring the type safety of our resolvers' code. Fortunately, we don't have to do this manually. Instead, we can use GraphQL Code Generator, which is a tool for generating code from your GraphQL schema and operations with a simple CLI. For additional information...