Just to share a repo for testing your dgraph schema with Jest against a docker image

This is the Github repo:

test your dgraph

You can pull request if need someting more :wink:

3 Likes

Very nice!

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.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.