Skip to content

What is the difference between DocumentNode vs Schema vs TypeDefs ? #5713

Answered by glasser
hazem-alabiad asked this question in Q&A
Discussion options

You must be logged in to vote

There are three types that can represent a GraphQL schema:

  • A string written in the GraphQL language, often called SDL, like type Query { field: ID! }.
  • An "abstract syntax tree" representing how a GraphQL language string is parsed. The root of this tree is called DocumentNode, because the top level of GraphQL syntax is called Document. You can get this from the graphql-js parse function or the graphql-tag/apollo-server gql function (which is a memoizing version of parse).
  • A GraphQLSchema object, which represents the schema more directly than as a parsed syntax tree. For example, this object contains a map from type name to objects representing that type (but doesn't have the concept of "o…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@glasser
Comment options

@smolinari
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by hazem-alabiad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants