I have added two new things, you can include other graphql files.
For example:
File: enum.graphql
enum Role {
ADMIN
DEVELOPER
}
File: schema.graphql
#include enum.graphql
type Job @auth(
query: {
rule: "{$ROLE: { eq: \"ADMIN\" } }"
}
){
id: ID!
title: String!
completed: Boolean!
command: String!
}
(Later you can npm run print to print full schema to stdout for production.)
If you want more flexibility you can do this:
File: yellow.config.js
module.exports = {
...
schema: "./schema/schema.js",
...
File: schema.js
const { quote, gql } = require('../setup')
const ADMIN = quote("ADMIN")
module.exports = gql`
type Job @auth(
query: {
rule: "{$ROLE: { eq: ${ADMIN} } }"
}
){
id: ID!
title: String!
completed: Boolean!
command: String!
}
`
You can split or do whatever you want, it’s javascript and gql.