Skip to content

nodecheck will find any GraphQL schema that is not conform to Node interface

Notifications You must be signed in to change notification settings

gqlgo/nodecheck

Repository files navigation

nodecheck

pkg.go.dev

nodecheck will find any GraphQL schema that is not conform to Node interface.

# Valid
type User implements Node {
  id: ID!
}

# Invalid. not conform to Node
type Community {
  name: String!
}

# Invalid. not conform to Node but id is exist 
type Item {
  id: ID!
}

How to use

A runnable linter can be created with multichecker package. You can create own linter with your favorite Analyzers. And nodecheck has independ flag for allow exclude types of nodecheck.

Full example

func main() {
	var excludes string
	flag.StringVar(&excludes, "excludes", "", "exclude GraphQL types for node check. it can specify multiple values separated by `,` and it can use regex(e.g .+Connection")
	flag.Parse()

	analyzer := nodecheck.Analyzer(excludes)

	multichecker.Main(
		analyzer,
	)
}

nodecheck provides a executable binary. So, you can get cmd tool via go install command.

$ go install github.com/gqlgo/nodecheck/cmd/nodecheck@latest

The nodecheck command receive two flags, schema and excludes. excludes can specify with regex format and it can receive multiple arguments separated by ','.

$ nodecheck -schema="server/graphql/schema/**/*.graphql" -excludes=.+Connection,.+Edge

Author

Appify Technologies, Inc.

About

nodecheck will find any GraphQL schema that is not conform to Node interface

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages