Commit Graph

56 Commits

Author SHA1 Message Date
Eugen Wissner 045b6d15fb Escape special characters in the encoded strings
Fixes #2.
2019-08-13 07:24:05 +02:00
Eugen Wissner a3354e7f58 Make all encoder functions return lazy text 2019-08-05 09:00:11 +02:00
Eugen Wissner 7a8a90aba8 Implement indentation in the encoder 2019-08-03 23:57:27 +02:00
Eugen Wissner 989e418cc2 Put spaces between tokens in the pretty printer 2019-08-02 13:52:51 +02:00
Eugen Wissner 4812c8f039 Introduce formatter type for the encoder
... to distinguish between minified and pretty printing.
2019-07-31 05:40:17 +02:00
Eugen Wissner d690d22ce8 Test the encoder with the unminified document 2019-07-27 07:31:09 +02:00
Eugen Wissner 282946560e Add singleError utility function 2019-07-23 07:22:32 +02:00
Eugen Wissner 1b5094b6a3 Parse the BOM header if any 2019-07-22 05:50:00 +02:00
Eugen Wissner f3b8d9b74c Make all exports explicit 2019-07-14 05:58:05 +02:00
Eugen Wissner eb40810f25 Replace tasty and HUnit with Hspec 2019-07-10 05:57:35 +02:00
Eugen Wissner 61879fb124 Constrain the resolvers with MonadIO
This replaces the most usages of MonadPlus, which is not appropriate for
the resolvers, since a resolver is unambiguously chosen by the name (no
need for 'mplus'), and the resolvers are often doing IO.
2019-07-08 10:15:47 +02:00
Eugen Wissner 22d4a4e583 Change the main namespace to Language.GraphQL 2019-07-07 06:31:53 +02:00
Eugen Wissner d7b6fd0329 Allow resolvers to return arbitrary nested lists 2019-07-05 20:05:04 +02:00
Eugen Wissner 6238b2fbfa Add nullable types 2019-07-03 17:54:50 +02:00
Eugen Wissner 91679650b5 Introduce monad transformer for resolvers
Now the errors in the resolvers can be handled and 3 tests throwing
errors pass now. Another test fail but it requires distinguisching
nullable and non-nullable values.
2019-07-02 20:07:26 +02:00
Eugen Wissner 79c734fa62 Replace Alternative with MonadPlus 2019-06-28 11:12:28 +02:00
Eugen Wissner ae4038eb47 Restore error handling 2019-06-27 08:00:59 +02:00
Eugen Wissner 3cc38343db Fix ambigious Int resolution in the lexer tests 2019-06-26 15:41:30 +02:00
Eugen Wissner 5e9bf9648d Parse queries with megaparsec 2019-06-21 10:44:58 +02:00
Danny Navarro 2b5648efda
When argument is not found return null
The relevant test was restored too.
2017-03-03 17:02:19 -03:00
Danny Navarro 285ccb0af9
Implement type instrospection tests
The main intention with this commit is to show a poor's man way to support type
instrospection.
2017-03-01 17:04:13 -03:00
Danny Navarro d2c138f8d1
Add basic Fragment Support
Only field names are supported for now.
2017-02-23 15:29:58 -03:00
Danny Navarro f35e1f949a
Define Schema using Core AST
Also, temporarily remove error reporting to simplify execution. This should be
restored once the new execution model is nailed.
2017-01-30 15:20:17 -03:00
Danny Navarro 5390c4ca1e
Split AST in 2
One AST is meant to be a target parser and tries to adhere as much as possible
to the spec. The other is a simplified version of that AST meant for execution.

Also newtypes have been replaced by type synonyms and NonEmpty lists are being
used where it makes sense.
2017-01-28 14:15:14 -03:00
Danny Navarro 933cfd2852
Tokenize number parser
The essential change hidden behind the code golfing is using the `tok`
combinator. This was making fail the Kitchen Sink test.
2016-12-18 12:19:59 -03:00
Danny Navarro aa66236081
Add homePlanet to test schema 2016-12-18 11:43:45 -03:00
Pweaver (Paul Weaver) a6c0d63049 add tests for errors in queries for queries in starwars tests 2016-07-08 18:10:14 -04:00
Pweaver (Paul Weaver) 624efbbb35 adds __typename tests to starwars testfile 2016-07-08 16:51:54 -04:00
Pweaver (Paul Weaver) cb73e9d53c adds the starwars tests for fragments
Also refactors some deplicate objects into a where clause
2016-07-08 16:11:03 -04:00
Matthías Páll Gissurarson d195389102 Added exception handling with Alternative constraint according to spec. 2016-03-14 01:01:24 +01:00
Danny Navarro d8a731fe30 Remove `StringValue` type 2016-02-22 13:59:38 +01:00
Danny Navarro 770df82718 Simplify Schema definition API
Now there is one `Resolver` type and the `Output` and `Scalar` types
have been removed. This should be closer to the final Schema definition
API.
2016-02-19 19:21:32 +01:00
Danny Navarro 8ee50727bd Overhaul Schema DSL
Aside of making the definition of Schemas easier, it takes care of
issues like nested aliases which previously wasn't possible. The naming
of the DSL functions is still provisional.
2016-02-18 13:49:02 +01:00
Danny Navarro 7131d1c142 Initial support for aliases in `execute` 2016-02-17 13:20:56 +01:00
Danny Navarro a0f12455c5 Add remaining tests with variables in arguments
The test with invalid ID is commented out until proper exception
handling is implemented.
2016-02-17 12:35:54 +01:00
Danny Navarro 98d2d41cda Initial support for variable substitution
The correspondent end-to-end test has been ported. The variable
definition still needs to be checked.
2016-02-15 14:43:52 +01:00
Danny Navarro 119f94b38e Clean up StarWars test queries 2016-02-15 11:19:05 +01:00
Danny Navarro 04d8d40b3a Split StarWars tests in different modules 2016-02-12 13:27:46 +01:00
Danny Navarro a088c81944 Handle Field arguments in Schema definition
The `Schema` has been overhauled to make `Output` monomorphic.
Traversing the `GraphQL` document is handled implicitly while defining
the `Schema`.

The 4th end-to-end test from `graphql-js` has been ported.
2016-02-12 12:51:18 +01:00
Danny Navarro 70fbaf359e Split Character data type into Droid and Human
`Character` is now a synonym of the sum type of `Droid` and `Human`.

For now I don't see the need to implement GraphQL Schema interfaces with
type classes or lens. Plain Haskell ADTs should be good enough.
2016-02-09 14:38:19 +01:00
Danny Navarro df8e43c9aa Handle Output enumerations in Schema definition
The third end-to-end test from graphql-js was implemented.
2016-02-09 13:31:28 +01:00
Danny Navarro 1561e62489 Extend `execute` for deeper queries
The second graphql-js end-to-end test was ported and passed
successfully.
2016-02-08 17:30:18 +01:00
Danny Navarro 53e101f35e Simplify JSON notation in tests 2016-02-05 12:54:04 +01:00
Danny Navarro c81ddb0335 Introduce `graphql` function
This simplifies Attoparsec parsing when executing a GraphQL
query.
2016-02-05 12:32:35 +01:00
Danny Navarro eca3c2d8d4 Generalize `Maybe` type constructor to any Monad
This allows schema definitions with side-effects for any type with a
Monadic/Alternative implementation like IO for example.
2016-01-30 12:29:49 +01:00
Danny Navarro b72cfc097a Fix for GHC-7.8.4 2016-01-26 13:57:58 +01:00
Danny Navarro 78e0d871d5 Garden 2016-01-26 13:38:02 +01:00
Danny Navarro bb685c9afa Rough implementation of `execute`
The first end-to-end test taken from `graphql-js` passes but this still
needs to be extended to support more general cases.

- `Data.GraphQL.Schema` has been heavily modified to support the
  execution model. More drastic changes are expected in this module.
- When defining a `Schema` ordinary functions taking fields as input are
  being used instead of maps. This makes the implementation of `execute`
  easier, and, arguably, makes `Schema` definitions more *Haskellish*.
- Drop explicit `unordered-containers` dependency. `Aeson.Value`s and
  field functions should be good enough for now.
2016-01-26 12:43:18 +01:00
Danny Navarro 4e5dc3433a Implement first StarWars end-to-end test
`execute` still needs to be implemented.
2015-10-19 12:19:39 +02:00
Danny Navarro 3f30a44d1d Test fixtures for Schema toplevel
This includes simplications to the Schema data types.
2015-10-17 17:49:56 +02:00