[์ต์
๊ฐ์ฒด์ autoSchemaFile์์ฑ ์ถ๊ฐ]
autoSchemaFile
- ์๋์ผ๋ก ์์ฑ๋ ์คํค๋ง๊ฐ ์์ฑ๋ ๊ฒฝ๋ก
GraphQLModule.forRoot({
autoSchemaFile: 'src/common/graphql/schema.gql',
}),
[์ต์
๊ฐ์ฒด์ typePaths์์ฑ ์ถ๊ฐ]
typePaths
- GraphQLModule์ด ์์ฑํ GraphQL SDL์คํค๋ง ์ ์ ํ์ผ ์์น
GraphQLModule.forRoot({
typePaths: ['./**/*.graphql'],
}),
[.graphql์ ์คํค๋ง ์ง์ ์์ฑ ํ์]
// cat.graphql
type Query {
cats: [Cat]
cat(id: ID!): Cat
}
type Mutation {
createCat(createCatInput: CreateCatInput): Cat
}
type Subscription {
catCreated: Cat
}
type Owner {
id: Int!
name: String!
age: Int
cats: [Cat!]
}
type Cat {
id: Int
name: String
age: Int
owner: Owner
}
input CreateCatInput {
name: String
age: Int
}
Code-first
๋ typescript๋ก ํด๋์ค๋ฅผ ์ง๋ฉด ํด๋น ํด๋์ค์ ํด๋นํ๋ graphql schema๋ฅผ ์์ฑ!
Schema-first
๋ graphql schema๋ฅผ ๋จผ์ ์์ฑ ํ ํด๋์ค๋ ์ธํฐํ์ด์ค ์์ฑ!