GraphQL Shorthand & Parser
Parse GraphQL shorthand notation into a JSON object that can be used to auto-generate schema files.
Can parse schemas and queries.
Motivation
- smaller, faster than the graphql library
- no dependency
- gracefull grammar
- easy to modify
Shorthand notation
// One of the films in the Star Wars Trilogy
enum Episode {
NEWHOPE
EMPIRE
JEDI
}
// A character in the Star Wars Trilogy
interface Character {
id: String!
name: String
friends: [Character]
appearsIn: [Episode]
}
// A humanoid creature in the Star Wars universe
type Human implements Character {
id: String!
name: String
friends: [Character]
appearsIn: [Episode]
homePlanet: String
}
// A mechanical creature in the Star Wars universe
type Droid implements Character {
id: String!
name: String
friends: [Character]
appearsIn: [Episode]
primaryFunction: String
}
type Query {
hero(episode: Episode): Character
human(id: String!): Human
droid(id: String!): Droid
}
Parsed notation to JSON
Authors
- Olivier Refalo - 2018 refresh
- Cameron Hunter - Origin code