Commit Graph

217 Commits

Author SHA1 Message Date
f671645043
Remove unused QueryError.TransformationError 2021-05-11 07:11:47 +02:00
1af95345d2 Deprecate internal error generation functions
The functions generating errors in the executor should be changed anyway
when we provide better error messages from the executor, with the error
location and response path. So public definitions of these functions are
deprecated now and they are replaced by more generic functions in the
executor code.
2021-05-10 09:43:39 +02:00
0d23df3da2
Provide an internal function to add errors
The old function, addErrMsg, takes only a string with an error
description, but more information is required for the execution errors:
locations and path. addErrMsg should be deprecated after the switching
to the new addError.
2021-05-09 12:42:02 +02:00
5a5f265fe4 Validate non-nullable values inside lists 2021-05-06 22:23:16 +02:00
2220f0ca56
Remove unused OverloadedStrings pragmas 2021-04-14 07:09:21 +02:00
5654b78935
Traverse input object properties once 2021-04-12 07:09:39 +02:00
328e6acdee
Emit list item errors once 2021-03-16 10:08:13 +01:00
4d762d6356
Add location information to list values 2021-03-14 12:19:30 +01:00
Ben Sinclair
ca0f0bd32d Fix some issues with directive definitions
I found some issues with directive definitions:

- I couldn't use `on FIELD_DEFINITION`, I believe because `FIELD` was parsed
  first in `executableDirectiveLocation`. I've combined both
  `executableDirectiveLocation` and `typetypeSystemDirectiveLocation` into one
  function which can reorder them to ensure every directive location gets a fair
  chance at parsing.

Not actually to do with directives, some literals weren't being parsed
correctly.

- The GraphQL spec defines list to be `[]` or `[Value]`, but empty literal lists
  weren't being parsed correctly because of using `some` instead of `many`.

- The GraphQL spec defines objects to be `{}` or `{Name: Value}`, but empty
  literal objects had the same issue.
2021-02-21 23:35:34 +11:00
10e4d64052 Replace Map with OrderedMap 2021-02-19 08:09:04 +01:00
d74e27e903 traverseMaybe OrderedMap 2021-02-15 09:04:16 +01:00
90d36f66b9 Combine value inserted into the OrderedMap 2021-02-14 14:46:06 +01:00
c1a1b47aea Add OrderedMap prototype 2021-02-13 06:56:10 +01:00
1e8405a6d6 Document AST.Document.escape 2021-02-11 12:02:08 +01:00
b27da54bf4 Provide custom Show instances for AST values 2021-02-04 08:12:12 +01:00
a034f2ce4d Validate values 2021-02-03 05:47:40 +01:00
ebf4f4d24e Update stack snapshot to 17.x. 2021-02-02 07:15:30 +01:00
1c7554c328 Validate variable usage is allowed in objects 2021-01-22 09:26:22 +01:00
c018657e25 Fix the type in messages when validating variables 2021-01-04 08:24:50 +01:00
71a5964c27 Rename variablesInAllowedPositionRule's variables
Name variablesInAllowedPositionRule's variables more meaningful.
2020-12-27 11:47:29 +01:00
22abf7ca58 Validate variable usages are allowed in arguments 2020-12-26 06:31:56 +01:00
5a6709030c Add show instances for AST type representation 2020-12-17 20:42:47 +01:00
2bcae9e0a7 Implement Show class for GraphQL type definitions
.. in the `Type` modules.
2020-12-14 22:36:27 +01:00
2dbc985dfc Validate fragment spreads are possible 2020-11-19 08:48:37 +01:00
86a0e00f7e Collect interface implementations 2020-11-17 08:10:32 +01:00
1f4eb6fb9b Implement basic "Field Selection Merging" rule 2020-11-15 10:11:09 +01:00
f5209481aa Extract collectFields function 2020-11-11 08:49:45 +01:00
4a3b4cb16d Fix singleFieldSubscriptionsRule fragment lookup
singleFieldSubscriptionsRule picks up a wrong fragment definition.
2020-11-06 08:33:51 +01:00
7c0b0ace4d Collect types once the schema is created 2020-10-07 05:24:51 +02:00
a91bc7f2d2 Validate required input fields 2020-10-05 14:51:21 +02:00
d5f518fe82 Validate required arguments 2020-10-03 07:34:34 +02:00
6daae8a521 Validate directives are in valid locations 2020-10-02 06:31:38 +02:00
56b63f1c3e Validate input object field names 2020-09-30 05:14:52 +02:00
466416d4b0 Validate directives are defined 2020-09-29 06:21:32 +02:00
4602eb1df3 Validate arguments are defined 2020-09-28 07:06:15 +02:00
ced9b815db Validate leaf selections 2020-09-26 09:06:30 +02:00
3373c94895 Validate field selections on composite types 2020-09-26 07:57:25 +02:00
9bfa2aa7e8 Validate input fields have unique names 2020-09-24 05:47:31 +02:00
e9a94147fb Validate variables are used 2020-09-22 04:42:25 +02:00
3e393004ae Validate all variables are defined 2020-09-21 07:28:40 +02:00
38c3097bcf Validate fragments are input types 2020-09-20 06:59:27 +02:00
21a7d9cce4 Validate variable names are unique 2020-09-19 18:18:26 +02:00
9a08aa5de7 Validate directives are unique per location 2020-09-18 07:32:58 +02:00
497b93c41b Validate arguments have unique names 2020-09-17 10:33:37 +02:00
6e644c5b4b Move path to the execution error
Since it isn't possible to get a path during validation, without
executing the query.
2020-09-16 09:12:49 +02:00
4c10ce9204 Use Seq as base monad in the validator
It is more natural to implement the logic: try to apply each rule to
each node.
2020-09-15 08:06:07 +02:00
08998dbd93 Validate fragments don't form cycles 2020-09-11 08:03:49 +02:00
c2c57b6363 Validate all fragments are used 2020-09-09 17:04:31 +02:00
f6ff0ab9c7 Validate fragments on composite types 2020-09-07 22:01:49 +02:00
d327d9d1ce Validate fragment spread type existence 2020-09-05 10:00:58 +02:00
14ed209828 Collect types from the subscription root 2020-09-04 19:12:19 +02:00
33318a3b01 Validate fragment spread target existence 2020-08-31 11:06:27 +02:00
7e78f98f09 Validate fragment name uniqueness 2020-08-28 08:32:21 +02:00
eebad8a27f Validate operation name uniqueness
Fixes #52.
2020-08-27 09:04:31 +02:00
e6a6926e18 Validate anonymous operation definitions 2020-08-26 18:58:48 +02:00
7355533268 Validate single root field in subscriptions 2020-08-25 21:03:42 +02:00
54dbf1df16 Remove encoder test based on old external files 2020-08-22 06:39:52 +02:00
1a788a6261 Loose monad condition on test methods 2020-08-20 20:53:47 +02:00
c60dd98fc5 Release 0.9.0.0 2020-07-24 21:58:49 +02:00
44d506d4b5 Draft the Validation API 2020-07-20 21:29:12 +02:00
b9d5b1fb1b Return a stream as well from graphql* functions 2020-07-19 07:36:06 +02:00
09135c581a Constrain base monad to MonadCatch
Let's try MonadThrow/MonadCatch. It looks nice at a first glance. The
monad transformer stack contains only the ReaderT, less lifts are
required. Exception subtyping is easier, the user can (and should)
define custom error types and throw them. And it is still possible to
use pure error handling, if someone doesn't like runtime exceptions or
need to run a query in a pure environment.

Fixes #42.
2020-07-17 07:05:03 +02:00
e24386402b Respect subscriptions in the executor
After the last commit there were a few places needed to be adjusted to
support subscriptions. This is done and a test case is added.

It is important to implement subscriptions now, because they require
changes to the library API, and they are a big missing part to finish
the executor. When the executor is finished, we can start to provide
more stable API without breaking everything every release. Validation
and introspection shouldn't require much changes to the API; AST would
require some changes to report good errors after the validation - this
is one thing I can think of.

Fixes #5.
2020-07-15 19:15:31 +02:00
ae2210f659 Support subscriptions
This is experimental support.
The implementation is based on conduit and is boring. There is a new
resolver data constructor that should create a source event stream. The
executor receives the events, pipes them through the normal execution
and puts them into the response stream which is returned to the user.

- Tests are missing.
- The executor should check field value resolver on subscription types.
- The graphql function should probably return (Either
  ResponseEventStream Response), but I'm not sure about this. It will
  make the usage more complicated if no subscriptions are involved, but
  with the current API implementing subscriptions is more
  difficult than it should be.
2020-07-14 19:37:56 +02:00
840e129c44 Parse subscriptions 2020-07-11 06:34:10 +02:00
04a58be3f8 Label parsers with help info
Fixes #36.
2020-07-10 08:43:47 +02:00
28781586a5 Parse comments in the front of definitions 2020-07-09 08:11:12 +02:00
c9e265f72c Return parser error location in a list
An error can have multiple locations which are returned in a listt with
key "locations".
2020-07-08 08:17:55 +02:00
b2d473de8d Export sum type for all GraphQL types 2020-07-06 19:10:34 +02:00
a6f9cec413 Handle errors using custom types
Fixes #32.
2020-07-05 14:36:00 +02:00
2f4310268a Merge Trans and Type.Out modules 2020-07-02 07:33:03 +02:00
8b164c4844 Move Core module out of AST 2020-06-30 10:28:10 +02:00
705e506c13 Combine Resolver and ActionT in ResolverT 2020-06-29 13:14:23 +02:00
91bd2d0d81 Fix list input coercion 2020-06-19 10:53:41 +02:00
882276a845 Coerce result
Fixes #45.
2020-06-13 07:20:19 +02:00
e8c54810f8 Merge selection sets 2020-06-12 07:58:08 +02:00
c37b9c88b1 Skip unknown fields 2020-06-10 11:42:00 +02:00
fdb1268213 Add custom Eq instances to the types 2020-06-09 10:02:34 +02:00
377c87045e Add description to the enum type values 2020-06-07 06:16:45 +02:00
4c9264c12c Coerce argument values properly
Fixes #44.
2020-06-06 21:22:11 +02:00
93a0403288 Resolve abstract types
Objects that can be a part of an union or interface should return
__typename as string.
2020-06-03 07:20:38 +02:00
d12577ae71 Define resolvers on type fields
Returning resolvers from other resolvers isn't supported anymore. Since
we have a type system now, we define the resolvers in the object type
fields and pass an object with the previous result to them.
2020-05-29 13:53:51 +02:00
c06d0b8e95 Add Union and Interface type definitions 2020-05-26 11:13:55 +02:00
61dbe6c728 Split input/output types and values into 2 modules 2020-05-25 07:41:21 +02:00
eb90a4091c Check point 2020-05-24 13:51:00 +02:00
7cd4821718 Don't fail on invalid fragments and variables 2020-05-23 21:49:57 +02:00
26cc53ce06 Reject variables as default values 2020-05-22 10:11:48 +02:00
c3ecfece03 Coerce variable values 2020-05-21 10:20:59 +02:00
a5c44f30fa Add basic output object type support 2020-05-14 22:16:56 +02:00
4c19c88e98 Accept resolvers given by the user as is 2020-05-13 16:21:48 +02:00
500cff20eb Separate Query and Mutation resolvers
Fixes #33 .
2020-05-10 18:32:58 +02:00
Dmitrii Skurikhin
2760bd8ee1 Don't encode controls as block strings
Fixes #39.

String containing control sequences should be encoded as simple strings
even if they contain newlines, since the block strings can contain only
SourceCharacters.
2020-04-10 11:19:36 +02:00
Dmitrii Skurikhin
30d6a0a58d encode null value as "null" 2020-03-31 10:04:34 +03:00
613e929d91 Update to Stack 15.x 2020-02-20 05:16:14 +01:00
c0e5e30e76 Document schema AST
Fixes #8.
2020-02-14 06:20:05 +01:00
67bebf853c Replace MonadIO constraint with just Monad
And make the tests use Identity instead of IO.
2020-02-01 20:46:35 +01:00
e8b82122c6 Try all extension parsers 2020-01-28 11:08:28 +01:00
a6bd2370b6 Parse type extensions
Signed-off-by: Eugen Wissner <belka@caraus.de>
2020-01-26 11:55:15 +01:00
b4a3c98114 Parse schema extensions 2020-01-25 16:45:39 +01:00
3ef27f9d11 Add "extend symbol" lexer to parse extensions 2020-01-17 12:29:06 +01:00