- When a type ends with
!
it means it will always return that type. - If it doesn't contain
!
it can return something like null users: [User!]!
- users will always return an array([]!) always containing a user(User!) == [User!]!
- String
- Boolean
- Int
- Float
- ID
- Nothing more than a regular schema
- These are functions that run when a query for something
They are as follows in the exact order
- There are
4
arguments that get passed to all resolver functions - object: useful when working with relational data. e.g a user having many posts
- args: Contains the operation arguments supplied (like a regular func)
- context (ctx): Useful when you want to share information across your GraphQL
- info: ...
- You can only have scalar values within a input type
input CreateUserInput {
name: String!
email: String!
age: Int
}
- Useful when you want to share information across your GraphQL resolvers
const server = new GraphQLServer({
typeDefs: './src/schema.graphql',
resolvers,
context: {
db,
},
});
- By default TypeORM infers the type based on the Typescript type.
- This column is inferred as type String aka VARCHAR in the database
@Column()
title: string;
@Entity
- Creates a table or document depending on the database type@PrimaryGeneratedColumn
- marks the table generated as the primary column and auto increments the value
@ObjectType()
- Marks a class as atype
known to GraphQL@Field()
- Create atype
known to GraphQL
mutation Login($email: String!, $password:String!){
login(email: $email, password: $password)
}