Define schema AST.
Large parts of the schema aren't exported publically. They will be made public during writing the parser. Fixes #6.
This commit is contained in:
parent
56d88310df
commit
78ee76f9d5
@ -1,7 +1,4 @@
|
||||
-- | This module defines an abstract syntax tree for the @GraphQL@ language based on
|
||||
-- <https://facebook.github.io/graphql/ Facebook's GraphQL Specification>.
|
||||
--
|
||||
-- Target AST for Parser.
|
||||
-- | Target AST for Parser.
|
||||
module Language.GraphQL.AST
|
||||
( Alias
|
||||
, Argument(..)
|
||||
|
@ -1,14 +1,20 @@
|
||||
-- | Various parts of a GraphQL document can be annotated with directives.
|
||||
-- This module describes locations in a document where directives can appear.
|
||||
module Language.GraphQL.AST.DirectiveLocation
|
||||
( DirectiveLocation
|
||||
, ExecutableDirectiveLocation
|
||||
, TypeSystemDirectiveLocation
|
||||
( DirectiveLocation(..)
|
||||
, ExecutableDirectiveLocation(..)
|
||||
, TypeSystemDirectiveLocation(..)
|
||||
) where
|
||||
|
||||
-- | All directives can be splitted in two groups: directives used to annotate
|
||||
-- various parts of executable definitions and the ones used in the schema
|
||||
-- definition.
|
||||
data DirectiveLocation
|
||||
= ExecutableDirectiveLocation ExecutableDirectiveLocation
|
||||
| TypeSystemDirectiveLocation TypeSystemDirectiveLocation
|
||||
deriving (Eq, Show)
|
||||
|
||||
-- | Where directives can appear in an executable definition, like a query.
|
||||
data ExecutableDirectiveLocation
|
||||
= Query
|
||||
| Mutation
|
||||
@ -19,6 +25,7 @@ data ExecutableDirectiveLocation
|
||||
| InlineFragment
|
||||
deriving (Eq, Show)
|
||||
|
||||
-- | Where directives can appear in a type system definition.
|
||||
data TypeSystemDirectiveLocation
|
||||
= Schema
|
||||
| Scalar
|
||||
|
@ -1,4 +1,7 @@
|
||||
-- | This module defines data structures representing a GraphQL document.
|
||||
-- | This module defines an abstract syntax tree for the @GraphQL@ language. It
|
||||
-- follows closely the structure given in the specification. Please refer to
|
||||
-- <https://facebook.github.io/graphql/ Facebook's GraphQL Specification>.
|
||||
-- for more information.
|
||||
module Language.GraphQL.AST.Document
|
||||
( Definition(..)
|
||||
, Document
|
||||
@ -17,20 +20,15 @@ import Language.GraphQL.AST
|
||||
)
|
||||
import Language.GraphQL.AST.DirectiveLocation
|
||||
|
||||
-- * Language
|
||||
|
||||
-- ** Document
|
||||
|
||||
-- | GraphQL document.
|
||||
type Document = NonEmpty Definition
|
||||
|
||||
type NamedType = Name
|
||||
|
||||
newtype Description = Description (Maybe Text)
|
||||
deriving (Eq, Show)
|
||||
|
||||
type RootOperationTypeDefinitions = NonEmpty RootOperationTypeDefinition
|
||||
|
||||
data RootOperationTypeDefinition
|
||||
= RootOperationTypeDefinition OperationType NamedType
|
||||
deriving (Eq, Show)
|
||||
|
||||
-- | All kinds of definitions that can occur in a GraphQL document.
|
||||
data Definition
|
||||
= ExecutableDefinition ExecutableDefinition
|
||||
@ -38,70 +36,108 @@ data Definition
|
||||
| TypeSystemExtension TypeSystemExtension
|
||||
deriving (Eq, Show)
|
||||
|
||||
-- * Type System
|
||||
|
||||
data TypeSystemDefinition
|
||||
= SchemaDefinition [Directive] RootOperationTypeDefinitions
|
||||
| TypeDefinition TypeDefinition
|
||||
| DirectiveDefinition Description Name ArgumentsDefinition DirectiveLocation
|
||||
deriving (Eq, Show)
|
||||
|
||||
-- ** Type System Extensions
|
||||
|
||||
data TypeSystemExtension
|
||||
= SchemaExtension SchemaExtension
|
||||
| TypeExtension TypeExtension
|
||||
deriving (Eq, Show)
|
||||
|
||||
-- ** Schema
|
||||
|
||||
type RootOperationTypeDefinitions = NonEmpty RootOperationTypeDefinition
|
||||
|
||||
data RootOperationTypeDefinition
|
||||
= RootOperationTypeDefinition OperationType NamedType
|
||||
deriving (Eq, Show)
|
||||
|
||||
data SchemaExtension
|
||||
= SchemaOperationExtension [Directive] RootOperationTypeDefinitions
|
||||
| SchemaDirectiveExtension (NonEmpty Directive)
|
||||
deriving (Eq, Show)
|
||||
|
||||
data TypeSystemExtension
|
||||
= SchemaExtension SchemaExtension
|
||||
| TypeExtension TypeExtension
|
||||
-- ** Descriptions
|
||||
|
||||
newtype Description = Description (Maybe Text)
|
||||
deriving (Eq, Show)
|
||||
|
||||
-- ** Types
|
||||
|
||||
data TypeDefinition
|
||||
= ScalarTypeDefinition Description Name [Directive]
|
||||
| ObjectTypeDefinition
|
||||
Description Name ImplementsInterfacesOpt [Directive] [FieldDefinition]
|
||||
| InterfaceTypeDefinition Description Name [Directive] [FieldDefinition]
|
||||
| UnionTypeDefinition Description Name [Directive] UnionMemberTypesOpt
|
||||
| EnumTypeDefinition Description Name [Directive] [EnumValueDefinition]
|
||||
| InputObjectTypeDefinition
|
||||
Description Name [Directive] InputFieldsDefinitionOpt
|
||||
deriving (Eq, Show)
|
||||
|
||||
data TypeExtension
|
||||
= ScalarTypeExtension Name (NonEmpty Directive)
|
||||
| ObjectTypeFieldsDefinitionExtension
|
||||
Name ImplementsInterfacesOpt [Directive] (NonEmpty FieldDefinition)
|
||||
| ObjectTypeDirectivesExtension
|
||||
Name ImplementsInterfacesOpt (NonEmpty Directive)
|
||||
| ObjectTypeImplementsInterfacesExtension Name ImplementsInterfaces
|
||||
| InterfaceTypeFieldsDefinitionExtension
|
||||
Name [Directive] (NonEmpty FieldDefinition)
|
||||
| InterfaceTypeDirectivesExtension Name (NonEmpty Directive)
|
||||
| UnionTypeUnionMemberTypesExtension Name [Directive] UnionMemberTypes
|
||||
| UnionDirectivesExtension Name (NonEmpty Directive)
|
||||
| EnumTypeEnumValuesDefinitionExtension
|
||||
Name [Directive] (NonEmpty EnumValueDefinition)
|
||||
| EnumTypeDirectivesExtension Name (NonEmpty Directive)
|
||||
| InputObjectTypeInputFieldsDefinitionExtension
|
||||
Name [Directive] InputFieldsDefinition
|
||||
| InputObjectTypeDirectivesExtension Name (NonEmpty Directive)
|
||||
deriving (Eq, Show)
|
||||
|
||||
-- ** Objects
|
||||
|
||||
newtype ImplementsInterfaces = ImplementsInterfaces (NonEmpty NamedType)
|
||||
deriving (Eq, Show)
|
||||
newtype ImplementsInterfacesOpt = ImplementsInterfacesOpt [NamedType]
|
||||
deriving (Eq, Show)
|
||||
|
||||
newtype UnionMemberTypes = UnionMemberTypes (NonEmpty NamedType)
|
||||
deriving (Eq, Show)
|
||||
newtype UnionMemberTypesOpt = UnionMemberTypesOpt [NamedType]
|
||||
data FieldDefinition = FieldDefinition Description Name ArgumentsDefinition Type
|
||||
deriving (Eq, Show)
|
||||
|
||||
newtype InputFieldsDefinition = InputFieldsDefinition (NonEmpty InputValueDefinition)
|
||||
deriving (Eq, Show)
|
||||
newtype InputFieldsDefinitionOpt = InputFieldsDefinitionOpt [InputValueDefinition]
|
||||
newtype ArgumentsDefinition = ArgumentsDefinition [InputValueDefinition]
|
||||
deriving (Eq, Show)
|
||||
|
||||
data InputValueDefinition
|
||||
= InputValueDefinition Description Name Type (Maybe Value) [Directive]
|
||||
deriving (Eq, Show)
|
||||
|
||||
newtype ArgumentsDefinition = ArgumentsDefinition [InputValueDefinition]
|
||||
-- ** Unions
|
||||
|
||||
newtype UnionMemberTypes = UnionMemberTypes (NonEmpty NamedType)
|
||||
deriving (Eq, Show)
|
||||
|
||||
newtype UnionMemberTypesOpt = UnionMemberTypesOpt [NamedType]
|
||||
deriving (Eq, Show)
|
||||
|
||||
-- ** Enums
|
||||
|
||||
data EnumValueDefinition = EnumValueDefinition Description Name [Directive]
|
||||
deriving (Eq, Show)
|
||||
|
||||
data FieldDefinition = FieldDefinition Description Name ArgumentsDefinition Type
|
||||
-- ** Input Objects
|
||||
|
||||
newtype InputFieldsDefinition
|
||||
= InputFieldsDefinition (NonEmpty InputValueDefinition)
|
||||
deriving (Eq, Show)
|
||||
|
||||
data TypeDefinition
|
||||
= ScalarTypeDefinition Description Name [Directive]
|
||||
| ObjectTypeDefinition Description Name ImplementsInterfacesOpt [Directive] [FieldDefinition]
|
||||
| InterfaceTypeDefinition Description Name [Directive] [FieldDefinition]
|
||||
| UnionTypeDefinition Description Name [Directive] UnionMemberTypesOpt
|
||||
| EnumTypeDefinition Description Name [Directive] [EnumValueDefinition]
|
||||
| InputObjectTypeDefinition Description Name [Directive] InputFieldsDefinitionOpt
|
||||
deriving (Eq, Show)
|
||||
|
||||
data TypeExtension
|
||||
= ScalarTypeExtension Name (NonEmpty Directive)
|
||||
| ObjectTypeFieldsDefinitionExtension Name ImplementsInterfacesOpt [Directive] (NonEmpty FieldDefinition)
|
||||
| ObjectTypeDirectivesExtension Name ImplementsInterfacesOpt (NonEmpty Directive)
|
||||
| ObjectTypeImplementsInterfacesExtension Name ImplementsInterfaces
|
||||
| InterfaceTypeFieldsDefinitionExtension Name [Directive] (NonEmpty FieldDefinition)
|
||||
| InterfaceTypeDirectivesExtension Name (NonEmpty Directive)
|
||||
| UnionTypeUnionMemberTypesExtension Name [Directive] UnionMemberTypes
|
||||
| UnionDirectivesExtension Name (NonEmpty Directive)
|
||||
| EnumTypeEnumValuesDefinitionExtension Name [Directive] (NonEmpty EnumValueDefinition)
|
||||
| EnumTypeDirectivesExtension Name (NonEmpty Directive)
|
||||
| InputObjectTypeInputFieldsDefinitionExtension Name [Directive] InputFieldsDefinition
|
||||
| InputObjectTypeDirectivesExtension Name (NonEmpty Directive)
|
||||
newtype InputFieldsDefinitionOpt
|
||||
= InputFieldsDefinitionOpt [InputValueDefinition]
|
||||
deriving (Eq, Show)
|
||||
|
Loading…
Reference in New Issue
Block a user