Initial commit
This includes a rough port of the data types at https://github.com/graphql/graphql-js/blob/master/src/language/ast.js
This commit is contained in:
commit
5af7136893
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.stack-work/
|
6
CHANGELOG.md
Normal file
6
CHANGELOG.md
Normal file
@ -0,0 +1,6 @@
|
||||
# Change Log
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [0.1] - 2015-09-12
|
||||
### Added
|
||||
- Data types for the GraphQL language.
|
140
Data/GraphQL.hs
Normal file
140
Data/GraphQL.hs
Normal file
@ -0,0 +1,140 @@
|
||||
module Data.GraphQL where
|
||||
|
||||
import Data.Text (Text)
|
||||
|
||||
-- * Name
|
||||
|
||||
type Name = Text
|
||||
|
||||
-- * Document
|
||||
|
||||
newtype Document = Document [Definition] deriving (Eq,Show)
|
||||
|
||||
data Definition = DefinitionOperation OperationDefinition
|
||||
| DefinitionFragment FragmentDefinition
|
||||
| DefinitionType TypeDefinition
|
||||
deriving (Eq,Show)
|
||||
|
||||
data OperationDefinition =
|
||||
Query (Maybe [VariableDefinition]) (Maybe [Directive]) SelectionSet
|
||||
| Mutation (Maybe [VariableDefinition]) (Maybe [Directive]) SelectionSet
|
||||
| Subscription (Maybe [VariableDefinition]) (Maybe [Directive]) SelectionSet
|
||||
deriving (Eq,Show)
|
||||
|
||||
data VariableDefinition = VariableDefinition Variable Type (Maybe DefaultValue)
|
||||
deriving (Eq,Show)
|
||||
|
||||
newtype Variable = Variable Name deriving (Eq,Show)
|
||||
|
||||
newtype SelectionSet = SelectionSet [Selection] deriving (Eq,Show)
|
||||
|
||||
data Selection = SelectionField Field
|
||||
| SelectionFragmentSpread FragmentSpread
|
||||
| SelectionInlineFragment InlineFragment
|
||||
deriving (Eq,Show)
|
||||
|
||||
data Field = Field (Maybe Alias) Name (Maybe [Argument])
|
||||
(Maybe [Directive])
|
||||
(Maybe SelectionSet)
|
||||
deriving (Eq,Show)
|
||||
|
||||
type Alias = Name
|
||||
|
||||
data Argument = Argument Name Value deriving (Eq,Show)
|
||||
|
||||
-- * Fragments
|
||||
|
||||
data FragmentSpread = FragmentSpread Name (Maybe [Directive])
|
||||
deriving (Eq,Show)
|
||||
|
||||
data InlineFragment =
|
||||
InlineFragment TypeCondition (Maybe [Directive]) SelectionSet
|
||||
deriving (Eq,Show)
|
||||
|
||||
data FragmentDefinition =
|
||||
FragmentDefinition Name TypeCondition (Maybe [Directive]) SelectionSet
|
||||
deriving (Eq,Show)
|
||||
|
||||
type TypeCondition = NamedType
|
||||
|
||||
-- * Values
|
||||
|
||||
data Value = ValueVariable Variable
|
||||
| ValueInt Int
|
||||
| ValueFloat Float
|
||||
| ValueString Text
|
||||
| ValueBoolean Bool
|
||||
| ValueEnum Name
|
||||
| ValueList ListValue
|
||||
| ValueObject ObjectValue
|
||||
deriving (Eq,Show)
|
||||
|
||||
newtype ListValue = ListValue [Value] deriving (Eq,Show)
|
||||
|
||||
newtype ObjectValue = ObjectValue [ObjectField] deriving (Eq,Show)
|
||||
|
||||
data ObjectField = ObjectField Name Value deriving (Eq,Show)
|
||||
|
||||
type DefaultValue = Value
|
||||
|
||||
-- * Directives
|
||||
|
||||
data Directive = Directive Name (Maybe [Argument]) deriving (Eq,Show)
|
||||
|
||||
-- * Type Reference
|
||||
|
||||
data Type = TypeNamed NamedType
|
||||
| TypeList ListType
|
||||
| TypeNonNull NonNullType
|
||||
deriving (Eq,Show)
|
||||
|
||||
newtype NamedType = NamedType Name deriving (Eq,Show)
|
||||
|
||||
newtype ListType = ListType Type deriving (Eq,Show)
|
||||
|
||||
data NonNullType = NonNullTypeNamed NamedType
|
||||
| NonNullTypeList ListType
|
||||
deriving (Eq,Show)
|
||||
|
||||
-- * Type definition
|
||||
|
||||
data TypeDefinition = TypeDefinitionObject ObjectTypeDefinition
|
||||
| TypeDefinitionInterface InterfaceTypeDefinition
|
||||
| TypeDefinitionUnion UnionTypeDefinition
|
||||
| TypeDefinitionScalar ScalarTypeDefinition
|
||||
| TypeDefinitionEnum EnumTypeDefinition
|
||||
| TypeDefinitionInputObject InputObjectTypeDefinition
|
||||
| TypeDefinitionTypeExtension TypeExtensionDefinition
|
||||
deriving (Eq,Show)
|
||||
|
||||
data ObjectTypeDefinition = ObjectTypeDefinition Name (Maybe Interfaces) [FieldDefinition]
|
||||
deriving (Eq,Show)
|
||||
|
||||
type Interfaces = [NamedType]
|
||||
|
||||
data FieldDefinition = FieldDefinition Name [InputValueDefinition]
|
||||
deriving (Eq,Show)
|
||||
|
||||
data InputValueDefinition = InputValueDefinition Name Type (Maybe DefaultValue)
|
||||
deriving (Eq,Show)
|
||||
|
||||
data InterfaceTypeDefinition = InterfaceTypeDefinition Name [FieldDefinition]
|
||||
deriving (Eq,Show)
|
||||
|
||||
data UnionTypeDefinition = UnionTypeDefinition Name [NamedType]
|
||||
deriving (Eq,Show)
|
||||
|
||||
data ScalarTypeDefinition = ScalarTypeDefinition Name
|
||||
deriving (Eq,Show)
|
||||
|
||||
data EnumTypeDefinition = EnumTypeDefinition Name [EnumValueDefinition]
|
||||
deriving (Eq,Show)
|
||||
|
||||
newtype EnumValueDefinition = EnumValueDefinition Name
|
||||
deriving (Eq,Show)
|
||||
|
||||
data InputObjectTypeDefinition = InputObjectTypeDefinition Name [InputValueDefinition]
|
||||
deriving (Eq,Show)
|
||||
|
||||
newtype TypeExtensionDefinition = TypeExtensionDefinition ObjectTypeDefinition
|
||||
deriving (Eq,Show)
|
30
LICENSE
Normal file
30
LICENSE
Normal file
@ -0,0 +1,30 @@
|
||||
Copyright J. Daniel Navarro (c) 2015
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
* Neither the name of J. Daniel Navarro nor the names of other
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
22
README.md
Normal file
22
README.md
Normal file
@ -0,0 +1,22 @@
|
||||
# Haskell GraphQL
|
||||
|
||||
[![Hackage Version](https://img.shields.io/hackage/v/graphql.svg)](https://hackage.haskell.org/package/graphql)
|
||||
|
||||
For now this only provides the data types to represent the GraphQL AST,
|
||||
but the idea is to be a Haskell port of
|
||||
[`graphql-js`](https://github.com/graphql/graphql-js). Next releases
|
||||
should include:
|
||||
|
||||
- [ ] Parser for the GraphQL language.
|
||||
- [ ] Data types for the GraphQL Schema language.
|
||||
- [ ] Parser for the GraphQL Schema language.
|
||||
- [ ] Interpreter of GraphQL requests.
|
||||
- [ ] Utilities to define GraphQL types and schema.
|
||||
|
||||
## Contact
|
||||
|
||||
Suggestions, contributions and bug reports are welcome.
|
||||
|
||||
Feel free to contact me, jdnavarro, on the #haskell channel on the
|
||||
[GraphQL Slack Server](https://graphql.slack.com). You can obtain an
|
||||
invitation [here](https://graphql-slack.herokuapp.com/).
|
3
TODO
Normal file
3
TODO
Normal file
@ -0,0 +1,3 @@
|
||||
- Data type accessors
|
||||
- Deal with Location
|
||||
- Deal with Strictness/unboxing
|
26
graphql.cabal
Normal file
26
graphql.cabal
Normal file
@ -0,0 +1,26 @@
|
||||
name: graphql
|
||||
version: 0.1
|
||||
synopsis: GraphQL Types
|
||||
description:
|
||||
Data types for the GraphQL language.
|
||||
homepage: https://github.com/jdnavarro/graphql-haskell
|
||||
bug-reports: https://github.com/jdnavarro/graphql-haskell/issues
|
||||
license: BSD3
|
||||
license-file: LICENSE
|
||||
author: Danny Navarro
|
||||
maintainer: j@dannynavarro.net
|
||||
copyright: Copyright (C) 2015 J. Daniel Navarro
|
||||
category: Web,Parsing
|
||||
build-type: Simple
|
||||
extra-source-files: README.md CHANGELOG.md stack.yaml
|
||||
cabal-version: >=1.10
|
||||
|
||||
library
|
||||
exposed-modules: Data.GraphQL
|
||||
build-depends: base >= 4.7 && < 5,
|
||||
text >=0.11.3.1
|
||||
default-language: Haskell2010
|
||||
|
||||
source-repository head
|
||||
type: git
|
||||
location: git://github.com/jdnavarro/graphql-haskell.git
|
5
stack.yaml
Normal file
5
stack.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
flags: {}
|
||||
packages:
|
||||
- '.'
|
||||
extra-deps: []
|
||||
resolver: lts-3.4
|
Loading…
Reference in New Issue
Block a user