graphql
Haskell GraphQL implementation
https://git.caraus.tech/OSS/graphql
| LTS Haskell 24.17: | 1.5.0.1 | 
| Stackage Nightly 2025-10-31: | 1.5.0.1 | 
| Latest on Hackage: | 1.5.0.1 | 
MPL-2.0 AND BSD-3-Clause licensed by Danny Navarro, Matthías Páll Gissurarson, Sólrún Halla Einarsdóttir
Maintained by [email protected]
This version can be pinned in stack with:
graphql-1.5.0.1@sha256:df998e120c26ec6fac48dc06218d369e4ab131d990d17bb08a6a8aa6a62cb1f9,3006Module documentation for 1.5.0.1
Depends on 10 packages(full list with versions):
Used by 1 package in nightly-2025-10-31(full list with versions):
GraphQL implementation in Haskell
See https://git.caraus.tech/OSS/graphql.
Report issues on the bug tracker.
API documentation is available through Hackage.
Further documentation will be made available in the Wiki.
Changes
Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Haskell Package Versioning Policy.
1.5.0.1 - 2025-06-19
Fixed
- Allow any 2.x QuickCheck version.
- Make the lexer and parser safe.
1.5.0.0 - 2024-12-03
Removed
- Remove deprecated ‘gql’ quasi quoter.
Changed
- Validate the subscription root not to be an introspection field
(singleFieldSubscriptionsRule).
1.4.0.0 - 2024-10-26
Changed
- Schema.Directiveis extended to contain a boolean argument, representing repeatable directives. The parser can parse repeatable directive definitions. Validation allows repeatable directives.
- AST.Document.Directiveis a record.
- gqlquasi quoter is deprecated (moved to graphql-spice package).
Fixed
- gqlquasi quoter recognizeds all GraphQL line endings (CR, LF and CRLF).
Added
- @specifiedBy directive.
1.3.0.0 - 2024-05-01
Changed
- Remove deprecated runCollectErrs,Resolution,CollectErrsTfrom theErrormodule.
1.2.0.3 - 2024-01-09
Fixed
- Fix corrupted source distribution.
1.2.0.2 - 2024-01-09
Fixed
- gqlremoves not only leading- \nbut also- \r.
- Fix non nullable type string representation in executor error messages.
- Fix input objects not being coerced to lists.
- Fix used variables are not found in the properties of input objects.
1.2.0.1 - 2023-04-25
Fixed
- Support hspec 2.11.
1.2.0.0 - 2023-02-28
Added
- Schema printing.
- Semigroupand- Monoidinstances for- AST.Document.Description.
- Support for vector 0.13.0.0 and transformers 0.6.1.0.
Fixed
- Fix resolvers returning a list in the reverse order.
Removed
- GHC 8 support.
- Cabal -json flag.
- Test.Hspec.GraphQL: moved to- graphql-spicepackage.
- CPP ifdef WITH_JSONblocks.
1.1.0.0 - 2022-12-24
Changed
- Removed deprecated Language.GraphQL.Errorfunctions:addErr,addErrMsg,singleError.
- Deprecate Resolution,CollectErrsTandrunCollectErrsin theErrormodule. It was already noted in the documentation that these symbols are deprecated, now a pragma is added.
- Language.GraphQL: Added information about the json flag and switching to graphql-spice for JSON support.
Added
- Partial schema printing: operation type encoder.
1.0.3.0 - 2022-03-27
Fixed
- Index position in error path. (Index and Segment paths of a field have been swapped).
- Parsing empty list as an argument.
Added
- quickCheck Parser test for arguments. Arbitrary instances for Language.GraphQL.AST.Document.
- Enhanced query error messages. Add tests for these cases.
- Allow version 2.0 of the text package.
1.0.2.0 - 2021-12-26
Added
- Serializeinstance for- Type.Definition.Value.
- VariableValueinstance for- Type.Definition.Value.
- Jsonbuild flag, enabled by default. JSON and Aeson support can be disabled by disabling this flag.
1.0.1.0 - 2021-09-27
Added
- Custom Showinstance forType.Definition.Value(for error messages).
- Path information in errors (path to the field throwing the error).
- Deprecation notes in the Errormodule forResolution,CollectErrsTandrunCollectErrs. These symbols are part of the old executor and aren’t used anymore, it will be deprecated in the future and removed.
- THmodule with the- gqlquasi quoter.
Fixed
- Error messages are more concrete, they also contain type information and wrong values, where appropriate and possible.
- If the field with an error is Non-Nullable, the error is propagated to the first nullable field, as required by the specification.
1.0.0.0 - 2021-07-04
Added
- Language.GraphQL.Execute.OrderedMapis a map data structure, that preserves insertion order.
- Language.GraphQL.Schema.schemaWithTypesconstructs a complete schema, including an optional schema description and user-defined types not referenced in the schema directly (for example interface implementations).
- Language.GraphQL.Schema.descriptionreturns the optional schema description.
- All errors that can be associated with a location in the query contain location information.
Fixed
- Parser now accepts empty lists and objects.
- Parser now accepts all directive locations.
- valuesOfCorrectTypeRuledoesn’t check lists recursively since the validation traverser calls it on all list items.
- valuesOfCorrectTypeRuledoesn’t check objects recursively since the validation traverser calls it on all object properties.
- Validation of non-nullable values inside lists.
- executeFieldshouldn’t assume that a selection has only one field with a given name, but it should take the first field. The underlying cause is a wrong pattern, which (because of the laziness) is executed only if the field has arguments.
Changed
- AST.Document.Value.Listand- AST.Document.ConstValue.ConstListcontain location information for each list item.
- Error:- singleError,- addErrand- addErrMsgare deprecated. They are internal functions used by the executor for error handling.
0.11.1.0 - 2021-02-07
Added
- Validate.Rules:- overlappingFieldsCanBeMergedRule
- possibleFragmentSpreadsRule
- variablesInAllowedPositionRule
- valuesOfCorrectTypeRule
 
- Type.Schema.implementationscontains a map from interfaces and objects to interfaces they implement.
- Show instances for GraphQL type definitions in the Typemodules.
- Custom Show instances for type and value representations in the AST.
- AST.Document.escapeescapes a single character in a- StringValue.
0.11.0.0 - 2020-11-07
Changed
- AST.Document.Selectionwraps additional new types:- Field,- FragmentSpreadand- InlineFragment. Thus validation rules can be defined more concise.
- AST.Document:- Argumentand- Directivecontain token location.
- AST.Document.Argumentcontains the- Valuewrapped in the- Node.
- AST.Lexer.colonand- AST.Lexer.atignore the result (it is always the
- same).
- Validate.Validation:- Validation.ruleswas removed.- Validation.rulescontained the list of rules, but the executed rules shouldn’t know about other rules.- ruleswas a part of the- Validationcontext to pass it easier around, but since the rules are traversed once now and applied to all nodes in the tree at the beginning, it isn’t required anymore.
- Validate.Validation.Error:- pathis removed since it isn’t possible to get the path without executing the query.
- Error.Error:- pathadded. It is currently always empty.
- Validate.Validation.Pathwas moved to- Error.
- Type.Schema.Schema: data constructor is hidden, fields are accessible with freestanding functions:- query,- mutation,- subscription,- directivesand- types.
Added
- Validate.Validation.Ruleconstructors:- SelectionRule
- FragmentRule
- FragmentSpreadRule
- ArgumentsRule
- DirectivesRule
- VariablesRule
- FieldRule
 
- Validate.Rules:- fragmentsOnCompositeTypesRule
- fragmentSpreadTargetDefinedRule
- fragmentSpreadTypeExistenceRule
- noUnusedFragmentsRule
- noFragmentCyclesRule
- uniqueArgumentNamesRule
- uniqueDirectiveNamesRule
- uniqueVariableNamesRule
- variablesAreInputTypesRule
- noUndefinedVariablesRule
- noUndefinedVariablesRule
- noUnusedVariablesRule
- uniqueInputFieldNamesRule
- fieldsOnCorrectTypeRule
- scalarLeafsRule
- knownArgumentNamesRule
- knownDirectiveNamesRule
- directivesInValidLocationsRule
- providedRequiredArgumentsRule
- providedRequiredInputFieldsRule
 
- AST.Document.Field.
- AST.Document.FragmentSpread.
- AST.Document.InlineFragment.
- AST.Document.Node.
- Type.In.Arguments: Type alias for an argument map.
- Type.Schema.Directiveand- Type.Schema.Directivesare directive definition representation.
- Type.Schema.schema: Schema constructor.
Fixed
- Collecting existing types from the schema considers subscriptions.
Removed
- AST.Document.Alias. Use- AST.Document.Nameinstead.
0.10.0.0 - 2020-08-29
Changed
- Test.Hspec.GraphQL.*: replace- IOin the resolver with any- MonadCatch.
- The Locationargument ofAST.Document.Definition.ExecutableDefinitionwas moved toOperationDefinitionandFragmentDefinitionsince these are the actual elements that have a location in the document.
- Validate.Rulesget the whole validation context (AST and schema).
Added
- Validate.Validationcontains data structures and functions used by the validator and concretet rules.
- Validate.Rules: operation validation rules.
0.9.0.0 - 2020-07-24
Fixed
- Location of a parse error is returned in a singleton array with key
locations.
- Parsing comments in the front of definitions.
- Some missing labels were added to the parsers, some labels were fixed to refer to the AST nodes being parsed.
Added
- ASTreexports- AST.Parser.
- AST.Document.Locationis a token location as a line and column pair.
- Executereexports- Execute.Coerce.
- Error.Erroris an error representation with a message and source location.
- Error.Responserepresents a result of running a GraphQL query.
- Type.Schemaexports- Typewhich lists all types possible in the schema.
- Parsing subscriptions.
- Error.ResponseEventStream,- Type.Out.Resolve,- Type.Out.Subscribeand- Type.Out.SourceEventStreamdefine subscription resolvers.
- Error.ResolverExceptionis an exception that can be thrown by (field value and event stream) resolvers to signalize an error. Other exceptions will escape.
- Test.Hspec.GraphQLcontains some test helpers.
- Validatecontains the validator and standard rules.
Changed
- Type.Out.Resolver: Interface fields don’t have resolvers, object fields have value resolvers, root subscription type resolvers need an additional resolver that creates an event stream.- Resolverrepresents these differences now and pairs a field with the function(s). Resolvers don’t have- ExceptT, errors are handled with- MonadThrow/- MonadCatch.
- All code from Transis moved toType.Outand exported byTypeandType.Out.
- AST.Corecontained only- Argumentswhich was moved to- Type.Definition.- ASTprovides now only functionality related to parsing and encoding, as it should be.
- Execute.executetakes an additional argument, a possible operation name and returns either a stream or the response.
- Errormodule was changed to work with dedicated types for errors and the response instead of JSON.
- graphqlSubstakes an additional argument, the operation name. The type of variable names is changed back to JSON since it is a common format and it saves additional conversions. Custom format still can be used with the underlying functions (in the- Executemodule). The function returns either a a stream or the resolved value.
- graphqlreturns either a stream or the resolved value.
- The constraint of the base monad was changed to MonadCatch(and it impliesMonadThrow).
Removed
- Trans.ActionTis an unneeded layer of complexity.- Type.Out.Resolverrepresents possible resolver configurations.
- Execute.executeWithName.- Execute.executetakes the operation name and completely replaces- executeWithName.
0.8.0.0 - 2020-06-20
Fixed
- The parser rejects variables when parsing defaultValue (DefaultValue). The
specification defines default values as Valuewithconstparameter and constants cannot be variables.AST.Document.ConstValuewas added,AST.Document.ObjectFieldwas modified.
- AST transformation should never fail.
- Arguments and fields with a missing variable as value should be left out.
- Invalid (recusrive or non-existing) fragments should be skipped.
 
- Argument value coercion.
- Variable value coercion.
- Result coercion.
- The executor should skip the fields missing in the object type and not fail.
- Merging subselections.
Changed
- Schema.Resolverwas moved to- Type.Out, it is a field and resolver function pair.
- AST.Core.Valuewas moved into- Type.Definition. These values are used only in the execution and type system, it is not a part of the parsing tree.
- Typemodule is superseded by- Type.Out. This module contains now only exports from other module that complete- Type.Inand- Type.Outexports.
- Error.CollectErrsTcontains the new- Resolutiondata structure.- Resolutionrepresents the state used by the executor. It contains all types defined in the schema and collects the thrown errors.
Added
- Type.Definitioncontains base type system definition, e.g. Enums and Scalars.
- Type.Schemadescribes a schema. Both public functions that execute queries accept a- Schemanow instead of a- HashMap. The execution fails if the root operation doesn’t match the root Query type in the schema.
- Type.Inand- Type.Outcontain definitions for input and output types.
- Execute.Coercedefines a typeclass responsible for input, variable value coercion. It decouples us a bit from JSON since any format can be used to pass query variables. Execution functions accept (- HashMap Name a) instead of- Subs, where a is an instance of- VariableValue.
Removed
- Schema.scalar,- Schema.wrappedScalar. They accepted everything can be converted to JSON and JSON is not suitable as an internal representation for GraphQL. E.g. GraphQL distinguishes between Floats and Integers.
- Schema.wrappedObject,- Schema.object,- Schema.resolversToMap. There is no need in special functions to construct field resolvers anymore, resolvers are normal functions attached to the fields in the schema representation.
- Schema.resolveis superseded by- Execute.Execution.
- Error.runAppendErrsisn’t used anywhere.
- AST.Core:- Document,- Directive,- Field,- Fragment,- Selection,- Alias- TypeConditionwere modified, moved into- Execute.Transform.Documentand made private. These types describe intermediate representation used by the executor internally. Moving was required to avoid cyclic dependencies between the executor and type system.
- AST.Coredoesn’t reexports anything.
0.7.0.0 - 2020-05-11
Fixed
- Result of null encoding
- Block strings encoding
- Result of tab and newline encoding
Added
- AST for the GraphQL schema.
- Type system definition parser.
- Trans.argument.
- Schema extension parser.
- Contributing guidelines.
- Schema.resolversToMap(intended to be used internally).
Changed
- Rename AST.DefinitionintoAST.Document.ExecutableDefinition.AST.Document.TypeSystemDefinitionandAST.Document.TypeSystemExtensioncan also be definitions.
- Move all AST data to AST.Documentand reexport them.
- Rename AST.OperationSelectionSettoAST.Document.SelectionSet.
- Make Schema.SubsaData.HashMap.Strict(was a functionkey -> Maybe valuebefore).
- Make AST.Lexer.ata text (symbol) parser. It was a char before and issymbol "@"now.
- Replace MonadIOwith a plainMonad. Since the tests don’t use IO, set the inner monad toIdentity.
- NonEmpty (Resolver m)is now- HashMap Text (NonEmpty (Resolver m)). Root operation type can be any type, therefore a hashmap is needed. Since types cannot be empty, we save the list of resolvers in the type as a non-empty list. Currently only “Query” and “Mutation” are supported as types. For more schema support is required. The executor checks now if the type in the query matches the type of the provided root resolvers.
Removed
- AST.Field,- AST.InlineFragmentand- AST.FragmentSpread. These types are only used in- AST.Selectionand- AST.Selectioncontains now 3 corresponding data constructors,- Field,- InlineFragmentand- FragmentSpread, instead of separate types. It simplifies pattern matching and doesn’t make the code less typesafe.
- Schema.scalarA.
- Schema.wrappedScalarA.
- Schema.wrappedObjectA.
- Schema.objectA.
- AST.Argument. Replaced with- AST.Argumentswhich holds all arguments as a key/value map.
0.6.1.0 - 2019-12-23
Fixed
- Parsing multiple string arguments, such as
login(username: "username", password: "password")would fail on the comma due to strings not having a space consumer.
- Fragment spread is evaluated based on the __typenameresolver. If the resolver is missing, it is assumed that the type condition is satisfied (all fragments are included).
- Escaping characters during encoding.
Added
- Directive support (@skip and @include).
- Pretifying multi-line string arguments as block strings.
0.6.0.0 - 2019-11-27
Changed
- Language.GraphQL.Encodermoved to- Language.GraphQL.AST.Encoder.
- Language.GraphQL.Parsermoved to- Language.GraphQL.AST.Parser.
- Language.GraphQL.Lexermoved to- Language.GraphQL.AST.Lexer.
- All Language.GraphQL.AST.Valuedata constructor prefixes were removed. The module should be imported qualified.
- All Language.GraphQL.AST.Core.Valuedata constructor prefixes were removed. The module should be imported qualified.
- Language.GraphQL.AST.Core.Objectis now just a HashMap.
- Language.GraphQL.AST.Transformis isn’t exposed publically anymore.
- Language.GraphQL.Schema.resolveaccepts a selection- Seq(- Data.Sequence) instead of a list. Selections are stored as sequences internally as well.
- Add a reader instance to the resolver’s monad stack. The Reader contains a Name/Value hashmap, which will contain resolver arguments.
Added
- Nested fragment support.
Fixed
- Consume ignored tokens after $and!. I mistakenly assumed that$variableis a single token, same asType!is a single token. This is not the case, for exampleVariableis defined as$ Name, so these are two tokens, therefore whitespaces and commas after$and!should be consumed.
Improved
- Language.GraphQL.AST.Parser.type_: Try type parsers in a variable definition in a different order to avoid using- but.
Removed
- Language.GraphQL.AST.Arguments. Use- [Language.GraphQL.AST.Argument]instead.
- Language.GraphQL.AST.Directives. Use- [Language.GraphQL.AST.Directives]instead.
- Language.GraphQL.AST.VariableDefinitions. Use- [Language.GraphQL.AST.VariableDefinition]instead.
- Language.GraphQL.AST.FragmentName. Use- Language.GraphQL.AST.Nameinstead.
- Language.GraphQL.Execute.Schema- It was a resolver list, not a schema.
- Language.GraphQL.Schema:- enum,- enumA,- wrappedEnumand- wrappedEnumA. Use- scalar,- scalarA,- wrappedScalarand- wrappedScalarAinstead.
0.5.1.0 - 2019-10-22
Deprecated
- Language.GraphQL.AST.Arguments. Use- [Language.GraphQL.AST.Argument]instead.
- Language.GraphQL.AST.Directives. Use- [Language.GraphQL.AST.Directives]instead.
- Language.GraphQL.AST.VariableDefinitions. Use- [Language.GraphQL.AST.VariableDefinition]instead.
Added
- Module documentation.
- Inline fragment support.
Fixed
- Top-level fragments.
- Fragment for execution is chosen based on the type.
0.5.0.1 - 2019-09-10
Added
- Minimal documentation for all public symbols.
Deprecated
- Language.GraphQL.AST.FragmentName. Replaced with Language.GraphQL.AST.Name.
- Language.GraphQL.Execute.Schema- It is not a schema (at least not a complete one), but a resolver list, and the resolvers should be provided by the user separately, because the schema can originate from a GraphQL document.- Schemaname should be free to provide a data type for the real schema later.
- Language.GraphQL.Schema:- enum,- enumA,- wrappedEnumand- wrappedEnumA. There are actually only two generic types in GraphQL: Scalars and objects. Enum is a scalar value.
Fixed
- Parsing block string values.
0.5.0.0 - 2019-08-14
Added
- executeWithNameexecutes an operation with the given name.
- Export Language.GraphQL.Encoder.definition,Language.GraphQL.Encoder.type'andLanguage.GraphQL.Encoder.directive.
- Export Language.GraphQL.Encoder.value. Escapes \ and “ in strings now.
Changed
- Operationincludes now possible operation name which allows to support documents with multiple operations.
- Language.GraphQL.Encoder.documentand other encoding functions take a- Formatteras argument to distinguish between minified and pretty printing.
- All encoder functions return Data.Text.Lazy.
Removed
- Unused Language.GraphQL.Encoder.spaced.
0.4.0.0 - 2019-07-23
Added
- Support for mutations.
- Error handling (with monad transformers).
- Nullable types.
- Arbitrary nested lists support.
- Potential BOM header parsing.
Changed
- attoparsec is replaced with megaparsec.
- The library is now under Language.GraphQL(instead ofData.GraphQL).
- HUnit and tasty are replaced with Hspec.
- Alternative/- MonadPlusresolver constraints are replaced with- MonadIO.
Removed
- Duplicates from Language.GraphQL.ASTalready available inLanguage.GraphQL.AST.Core.
- All module exports are now explicit, so private and help functions aren’t exported anymore.
0.3 - 2015-09-22
Changed
- Exact match numeric types to spec.
- Names follow now the spec.
- AST slightly different for better readability or easier parsing.
- Replace golden test for test to validate parsing/encoding.
Added
- Parsing errors in all cases where Alternativeis used.
- GraphQL encoder.
Fixed
- Expect braces inputValueDefinitionsinstead of parens when parsing.
0.2.1 - 2015-09-16
Fixed
- Include data files for golden tests in Cabal package.
- Support for ghc-7.8.
0.2 - 2015-09-14
Added
- Rudimentary parser for GraphQLwhich successfully parses the sample filekitchen-sink.graphqlfromgraphql-jstests.
- Golden test for kitchen-sink.grahqlparsing.
Changed
- Many optional data types in GraphQldidn’t need to be wrapped in aMaybe.
- Some newtypes became type synonyms for easier parsing.
0.1 - 2015-09-12
Added
- Data types for the GraphQL language.
