haskell-graphql / graphql-api

Write type-safe GraphQL services in Haskell
BSD 3-Clause "New" or "Revised" License
406 stars 35 forks source link

Schema vs SchemaDocument #188

Open dmjio opened 6 years ago

dmjio commented 6 years ago

Why not unify Schema and SchemaDocument as the same type?

jml commented 6 years ago

Because they are different things.

SchemaDocument is an AST-level representation. The type allows everything that's syntactically valid, and values are constructed with a parser.

Schema is a known valid GraphQL schema. It is guaranteed to be fully validated, and excludes many syntactically valid values that are not valid GraphQL.

This means the parser only has to worry about syntax, the validator only has to worry about validation, and the executor doesn't have to worry about dodgy input.

What lead you to ask the question?