Skip to content

Commit 0b46e3b

Browse files
authored
v1.2.0 Release (#192)
* Foundation for initial v1.2 release (#157) * Build toplevel IR structs Restarted this branch. * Add Union, Enum to IR * Fix Directive IDL generation * Stub for IR directive * IR IDL Object, minus fields * basic input * IR directive * error t * Add (Type)Definition to IR IDL nodes * Fix reporting of syntax errors * Support for directives on interfaces * IR IDL UnionTypeDefinition, with directives * Test for IDL Interfaces, normalize Language & IR refs to "InterfaceTypeDefinition" * pass doc through * merge fix * [Input]ObjectDefinition -> [Input]ObjectTypeDefinition * Fix some missed file moves for naming changes * non null and friend * list type vs list * IR IDL FieldDefinitions, w/ types & directives * Cleanup some AST struct type defs, style * Cleanup AST struct defstructs, types * IR IDL ScalarTypeDefinition w/ directive support * IR IDL Directive definitions * IR IDL FieldDefinition w/ ArgumentDefinitions * IR IDL InputObjectTypeDefinition w/ fields & directives * IR -> Blueprint * Typespec fixes, start getting strict about keys * Get serious about @SPEC and @enforce_keys * Build Blueprint Field.t w/ Input.Argument.t * Blueprint Object, Field, Directive args * EnumTypeDefinition & Perf: `Enum.map` vs. `for` * Fix typespec typo * Add scalar definitions to blueprint types * Blueprint variable definitions * Naive pipelining of Parse -> Blueprint * Simplify pipeline flow * Add stub for variables phase * AST responsible for Blueprint conversion * initial mapping code * might help if I included the file * mapping for IDL types * Pipeline configuration * Basic Phase.Operation.Variables using Mapper * Phase Variables -> Input, as it handles literals * Split Phase Input -> [Variables, Arguments] * Blueprint.IDL -> Blueprint.Schema * Blueprint.{List,Named,NonNull}Type -> Blueprint.TypeReference.{List,Name,NonNull} * Add Blueprint.Document namespacing * Since it's not "mapping," call it Transform for now * Add Deprecation and EnumValueDefinition * Move Directive back; it's in schema and documents * Blueprint.TypeReference.unwrap/1 * SourceLocation supported by major document nodes * Phase behaviour check_input/1 for input prereqs * Fix Phase.Document.Variables @moduledoc * Support fragment types * Fix selection types * Beginning of work on flattening * Flatten fragments from `selections` into `fields` * Start document validation with NoFragmentCycles * Add cycle test for validation (currently failing) * Cleanup fragment tests, handle pipeline halting * Foundation for directive expansion phase (#126) * Basic Document.Schema phase to support directive expansion * Core expansion logic * Bump travis settings * Set schema_node for operations and fragments * Schema nodes for inline fragments * Schema nodes for root fields of operations, fragments * Fill in schema nodes for simple arguments * Deeply nested input value schema-tagging, ignoring list/non-null * Simple cases for directive expansion * Generate data structure from Blueprint argument values (#128) * Blueprint.Input.Argument.t: provided_value -> normalized_value * Argument: value -> literal_value * Argument: Add `data_value` * Clean up some debugging * Phase.Document.Arguments -> Phase.Document.Arguments.Normalize * Object and scalar argument values * Aruguments.Data phase: Support for lists of scalars - Still have some regressions to fix * Build argument data ignoring non-null/list as needed * Start building test harness for validation tests * Foundation of validation test harness * Build out assertions for validation test harness * Initial pass/fail tests for ArgumentsOfCorrectType validation * ArgumentsOfCorrectType "happy path" tests * initial {version} test passed (#129) * initial {version} test passed * basic tests with arguments work * handle list return values * more resolution work * FSE test passing * collect errors into result * more execution * Made Scalars parse Blueprint nodes vs AST * Passing: All non-collection ArgumentsOfCorrectType * List input coercion * Support deep-flagging of problems in data phase * More source locations, break out list validation * Merge list item type validation w/ arg. Passing. * Support for reporting unknown fields * Simplify error checking, application * ArgumentsOfCorrectType ALL PASSING * KnownArgumentNames validation * ProvidedNonNullArguments validation * Actually add files. update data phase moduledoc. * UniqueArgumentNames - Add validation module - Add validation helper module - Allow @directive directive * UniqueInputFieldNames validation * Cleanup prewalks * Wire validations into pipeline * Add docs, specs, and comments. * Work on test failures * Phase tests passing * Skip @tag :old_errors for now, fix pipeline test * Pass variables as only part of provided_values * Add 'directive' to parser rule * Support for 'on' in certain contexts * Directive expansion (#136) * Basics for Doc/Schema KnownDirectives validation * Cleanup some old validations, protocol * Start to deal with validation of IDL documents * Work on directives validation * KnownDirectives validation, cleanup * Update flatten to pay attention to directive flags * Ensure KnownDirectives validation runs for schemas * coerce variables given as strings for enums (#139) * coerce variables given as strings for enums * fixes * Structural / Schema-related Validations (#138) * LoneAnonymousOperation * KnownFragmentNames, inline fragment parser tweak * Phase.Validation.KnownTypeNames * Core utilities for NoUndefinedVariables validation * NoUndefinedVariables * Missing files * NoUnusedVariables * NoUnusedFragments * UniqueFragmentNames * UniqueOperationNames * UniqueVariableNames * Extract error message to function * Fix parser warning * Restructure flags as a map for matching (#144) * Clear out old parser code (#145) * clean up warnings * use current operation when resolving * use custom default resolvers * non null fields are only invalid if they are also not deprecated * don't try to expand type if the parent schema node already is the type we want (#148) * Execution test cleanup (#146) * Use current operation in execution * No missing input stubs for deprecated fields * Restructure result tree, attach to operation * Clean out old execution, more type massaging * fix warnings * Fix introspection tests, add debug phase * Fix non-typeless inline fragment tests * v1.2: Wrap up all non-error related test failures (#152) * Fix flattening * All happy path tests green! * Fix compilation warnings * v1.2: Build errors from Blueprint tree (#153) * Towards resolution building Phase.Error structs * 484 tests, 22 failures & field suggestions * Validation: VariablesAreInputTypes, tests * GREEN * ScalarLeafs validation * Basic pipeline tests, hook in ScalarLeafs * Update introspection test * v1.2: Basic Documentation Pass (#159) * @moduledoc for toplevel & adapter cleanup * First pass at CHANGELOG, bump version * Small wording change, typo * Enforce validation errors skipping resolution (#164) * Don't include data fields if validation fails * Work towards pipeline cleanup * Return values from phases can control the pipeline * Insert after a phase, ensure adapter * Simplify/unify options to phases (#166) * Simplify/unify options to phases * Cleanup tests, check for operation during validation * Use concrete resolvers for interface fields. * Temporarily add in Debug phase post-flatten * Fix a type condition check in resolution, docs. * Move to %Absinthe.Resolution{} * failing test case (#168) * failing test case * bug fix * More CHANGELOG fun * 2 and 3 arity function support * version bump * changelog entry * Fix introspection breakage on lists, add test (#171) * bug fix: actually stick the full field info on the definition * alpha 2 * Fix unhandled argument variable cases. (#160) * failing test cases with various nested variable situations * initial input value work * schema doesn't gag on basic argument values * schema doesn't gag on basic argument values * basic missing flagging * list values * once again back to basic arguments * solve infinite loop issue * handle list coercion * handle missing variables properly * tons of validation progress * all passing arguments of correct type * 33 test failures * charlists => strings" * more test fixes * more test progress * remove some duplicate errors * handle nil variables properly * arguments tests are green * just uniqueness errors now * omg they're all greeN' * remove some unneeded test * obselete not necessary * beta commit * updated docs deps * coerce string inputs to enum inputs when they're found as part of a variable (#178) * Fix #174 (#179) * failing test case to exhibit bug * Fixes #174 by doing a deep merge on the fragments * Fixed type resolution of wrapped types (#180) * Fixed type resolution of wrapped types * Code tidy-up * Fixed Pipeline.without/2 (#181) * Resolution Plugin System. Includes Async (#183) * basic async works * now we'll run resolution as many times as necessary becuase we have an accumulator * fleshed out resolution plugin system * cleanup and improve plugin API * it would help if I added all the files * stabilization of plugin API. also docs * tests * fix dumb mistake * improved docs * Batching (#184) * working batching * improved docs * allow timeout opts for async * improved batching and plugin docs * fix merge errors * version bump * correct version * ensure we dont' strip out false input object fields from args * Fix for resolution of list of union type (#188) * moduledoc false all the things (#186) * relocate the call function for resolution functions to somewhere more public facing * Metadata utility (#187) * Add `meta` notation macro and `Type.meta/2` utility * Add Absinthe.Type.meta/1 * v1.2 updates to README, CHANGELOG (#191) * Reformat CHANGELOG * Add CHANGELOG entry on validation errors * README cleanup * Some CHANGELOG placeholders for Ben * fill out changelog * Add metadata mention
1 parent 31a930a commit 0b46e3b

272 files changed

Lines changed: 14058 additions & 4206 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
erl_crash.dump
77
*.ez
88
src/*.erl
9+
.tool-versions*

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
language: elixir
2-
elixir: 1.2.0
2+
elixir: 1.3.0
33
notifications:
44
recipients:
55
- bruce.williams@cargosense.com
66
- ben.wilson@cargosense.com
77
otp_release:
88
- 18.0
9+
- 19.0
910
script: "MIX_ENV=test mix local.hex --force && MIX_ENV=test mix do deps.get, test"

CHANGELOG.md

Lines changed: 138 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,163 @@
11
# Changelog
22

3+
## v1.2
4+
5+
## Overview
6+
7+
Absinthe now generates a richer "intermediate representation" of query
8+
documents (see `Absinthe.Blueprint`) from the document AST. This representation
9+
then serves as the data backbone for processing during later phases.
10+
11+
Rather than the integrated validation-during-execution approach used in
12+
previous versions-- and rather than using a few "fat" phases (eg, "Parsing",
13+
"Validation", "Execution") as in other implementations -- Absinthe treats
14+
all operations (parsing, each individual validation, field resolution, and
15+
result construction) as a pipeline (see `Absinthe.Pipeline`) of discrete
16+
and equal phases. This allows developers to insert, remove, switch-out, and
17+
otherwise customize the changes that occur to the intermediate representation,
18+
and how that intermediate representation turns into a result. Future releases
19+
will further this model and continue to make it easier to modify Absinthe's
20+
processing to support the unique needs of developers.
21+
22+
### Breaking Changes
23+
24+
#### Deprecations and Errors
25+
26+
Absinthe no longer automatically adds deprecations to result
27+
errors. (Although this is possible with the addition of custom
28+
phases.)
29+
30+
#### More Strict Input Value Parsing
31+
32+
Absinthe now more closely adheres to the GraphQL specification's rules
33+
about input value coercion, to include:
34+
35+
- Int: Disallowing automatic coercion of, eg, `"1"` to `1`
36+
- String: Disallowing automatic coercion of, eg, `1` to `"1"`
37+
- Enum: Disallowing quoted values, eg, `"RED"` vs `RED`
38+
39+
Furthermore scalar type `parse` functions now receive their value as
40+
`Absinthe.Blueprint.Input.t` structs. If you have defined your own
41+
custom scalar types, you may need to modify them; see
42+
`lib/absinthe/type/built_ins/scalars.ex` for examples.
43+
44+
#### Validation Errors Prevent Resolution
45+
46+
In accordance with the GraphQL Specification, if any errors are added
47+
during document validation, no resolution will occur. In the past,
48+
because validation was done on-the-fly during resolution, partial
49+
resolution, just returning `null` for fields (in a way that would be
50+
invalid, according to the spec) was possible.
51+
52+
(Notably, this release includes a very large number of new document
53+
validations.)
54+
55+
#### No AST Nodes in Resolution
56+
57+
The raw AST nodes are no longer provided as part of the "info" argument passed
58+
to resolve functions. If you have built logic (eg, Ecto preloading) based on
59+
the AST information, look at the `definition` instead, which is a Blueprint
60+
`Field` struct containing a `fields` array of subfields. These fields have
61+
passed validation and have been flattened from any fragments that may have
62+
been used in the original document (you just may want to pay attention to
63+
each field's `type_conditions`).
64+
65+
#### List Coercion
66+
67+
Fields and arguments with list types are now automatically coerced if given a
68+
single item. For example if you have `arg :ids, list_of(:id)` Absinthe will coerce
69+
a document like `foo(ids: 1)` into `foo(ids: [1])`.
70+
71+
This is also true for resolution functions. If your field has a return type of
72+
`list_of(:user)` and your resolution function returns `{:ok, %User{}}`, the value
73+
is wrapped. It is as though you returned `{:ok, [%User{}]}`.
74+
75+
#### Simpler Adapters
76+
77+
Adapters now only use `to_internal_name/2` and `to_external_name/2` as the
78+
`Absinthe.Blueprint` intermediate representation and schema application
79+
phase removes the need for whole document conversion. If you have defined
80+
your own adapter, you may need to modify it.
81+
82+
#### Mix Task Removal
83+
84+
The IDL generating mix task (`absinthe.schema.graphql`) has been temporarily
85+
removed (due to the extent of work needed to modify it for this release), but
86+
it will reappear in a future release along with integrated schema compilation
87+
from GraphQL IDL.
88+
89+
### Other Changes
90+
91+
#### Resolution Functions
92+
93+
Support for 3-arity resolution functions. Resolution functions accepting 3
94+
arguments will have the current "source" (or parent) object passed as the
95+
first argument. 2-arity resolution functions will continue to be supported.
96+
97+
The following resolutions functions are equivalent:
98+
99+
```elixir
100+
fn source, args, info -> {:ok, source.foo} end
101+
fn args, %{source: source} -> {:ok, source.foo} end
102+
```
103+
104+
#### Resolution Plugins (+ Async & Batching)
105+
106+
v1.2 features a Resolution Plugin mechanism. See the docs in the
107+
`Absinthe.Resolution.Plugin` module for more information.
108+
109+
#### Resolution Info
110+
111+
In previous versions, the last argument to resolution functions was an
112+
`Absinthe.Execution.Field` struct. It is now an `Absinthe.Resolution` struct.
113+
While the struct has most of the same information available, the AST nodes
114+
is no longer provided. See "Breaking Changes" above.
115+
116+
#### Custom Type Metadata
117+
118+
To further support extensibility, types and fields can be annotated using the
119+
`Absinthe.Schema.Notation.meta/2` macro, and metadata extracted using
120+
`Absinthe.Type.meta/1` and `Absinthe.Type.meta/1`. This metadata facility has
121+
been added for objects, input objects, enums, scalars, unions, interfaces, and
122+
fields.
123+
3124
## v1.1.7
4125

5-
Bugfixes
126+
### Bugfixes
127+
6128
- Fix execution of nested fragment spreads with abstract condition types.
7129

8130
## v1.1.6
9131

10-
Bugfixes
132+
### Bugfixes
133+
11134
- Support adapting InterfaceDefinition structs; caused a warning when
12135
running the `absinthe.schema.graphql` mix task.
13136
- Fix missing newline after scalar type definitions in IDL output by
14137
the `absinthe.schema.graphql` mix task.
15138

16139
## v1.1.5
17140

18-
Bugfixes
141+
### Bugfixes
142+
19143
- Correctly stringify serialized default values when introspecting
20144

21145
## v1.1.4
22146

23-
Bugfixes
147+
### Bugfixes
24148

25149
- Fix bug where fragments with abstract type conditions were not applied in some cases
26150
- Correctly serialize default values based on the underlying type for introspection
27151

28152
## v1.1.3
29153

30-
Bugfixes:
154+
### Bugfixes
31155

32156
- Fix regression where documents containing multiple operations could not have the operation selected
33157
- Fix issues with returning union types.
34158
- Fix bug where field names inside argument errors were not returned in the adapted format.
35159

36-
Mix Tasks:
160+
### Mix Tasks
37161

38162
- `absinthe.schema.json` now requires schema to be given as an `--schema`
39163
option, but supports the `:absinthe` `:schema` application configuration
@@ -42,13 +166,13 @@ Mix Tasks:
42166

43167
## v1.1.2
44168

45-
Bugfixes:
169+
### Bugfixes
46170

47171
- Include `priv/` in package for `absinthe.schema.json` task.
48172

49173
## v1.1.1
50174

51-
Bugfixes:
175+
### Bugfixes
52176

53177
- Variables with input objects and lists inside other input objects work properly.
54178

@@ -65,7 +189,7 @@ Absinthe, especially around:
65189

66190
In terms of breaking changes, there is one you should know about:
67191

68-
## Enum values
192+
### Enum values
69193

70194
As of v1.1.0, Absinthe, by default, adheres to the specification recommendation
71195
that enum values be provided in ALLCAPS. If you have existing enum definitions
@@ -88,7 +212,7 @@ approach uses macros -- to simplify the visual complexity of schemas, provide
88212
more comprehensive feedback on correctness, and increase performance, since we
89213
can now execute any necessary checks and transformations during compilation.
90214

91-
## Type Definitions
215+
### Type Definitions
92216

93217
Here's an example of an object definition in the _old_ notation style:
94218

@@ -143,7 +267,7 @@ In general, attributes of types are now available as nested macros
143267
function; now you use the singular `field` macro to define each individual
144268
field).
145269

146-
## Type Modules
270+
### Type Modules
147271

148272
In the past, this is how you would import types from another module:
149273

@@ -193,15 +317,15 @@ The following changes are required if you're upgrading from the previous version
193317

194318
The second argument passed to resolution functions has changed from
195319
`Absinthe.Execution.t` to a flatter, simpler data structure,
196-
`Absinthe.Execution.Field.t`. This struct will be a more carefully curated
320+
`Absinthe.Resolution.t`. This struct will be a more carefully curated
197321
selection of metadata and match more closely to values in the JS
198322
reference implementation.
199323

200-
See the typedoc for information about `Absinthe.Execution.Field.t`, and change
324+
See the typedoc for information about `Absinthe.Resolution.t`, and change
201325
any advanced resolvers to use this new struct. The most likely change will be
202326
the use of `source` instead of `resolution.target`.
203327

204-
## v0.4.0
328+
### v0.4.0
205329

206330
The following changes are required if you're upgrading from the previous version:
207331

README.md

Lines changed: 53 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,69 @@
77

88
Goals:
99

10-
- Complete implementation of the [GraphQL Working Draft](https://facebook.github.io/graphql), dated April 2016.
10+
- Complete implementation of the [GraphQL Working Draft](https://facebook.github.io/graphql).
1111
- An idiomatic, readable, and comfortable API for Elixir developers
12-
- Detailed error messages and documentation
13-
- A focus on robustness and production-level performance
12+
- Extensibility based on small parts that do one thing well.
13+
- Detailed error messages and documentation.
14+
- A focus on robustness and production-level performance.
1415

1516
Please see the website at [http://absinthe-graphql.org](http://absinthe-graphql.org).
1617

17-
## Features
18-
19-
- Parser
20-
- All AST types
21-
- Fragments and type conditions
22-
- Line number reporting
23-
- ~~Column number reporting~~ (Not currently available due to Leex tokenizer constraint)
24-
- Schema definition
25-
- All types (eg, Object, Input Object, Enum, Union, Interface, Scalar)
26-
- Circular type references
27-
- Support for [custom scalars](http://absinthe-graphql.org/guides/custom-scalars/)
28-
- Support for custom directives
29-
- Field, argument, and enum value [deprecation](http://absinthe-graphql.org/guides/deprecation/)
30-
- Compile-time schema validation
31-
- [Introspection](http://absinthe-graphql.org/guides/introspection/), compatible with GraphiQL
32-
- Query execution
33-
- General
34-
- Named fragments, inline fragments, and fragment spreads with type conditions
35-
- `@skip` and `@include` directives
36-
- [Adapter](http://absinthe-graphql.org/guides/adapters/) mechanism to support conversion between camelCase query documents
37-
and snake_cased schema definition.
38-
- Client support
39-
- Generation of JSON and GraphQL (IDL) introspection documents for use by client frameworks
18+
## Why Use Absinthe?
19+
20+
Absinthe goes far beyond GraphQL specification basics.
21+
22+
### Easy-to-Read, Fast-to-Run Schemas
23+
24+
Absinthe schemas are defined using easy-to-read macros that build and verify
25+
their structure at compile-time, preventing runtime errors and increasing
26+
performance.
27+
28+
### Pluggability
29+
30+
The entire query processing pipeline is configurable. Add, swap out, or remove
31+
the parser, individual validations, or resolution logic at will, even on a
32+
per-document basis.
33+
34+
### Advanced Resolution
35+
36+
Absinthe includes a number of advanced resolution features, to include:
37+
38+
- Asynchronous field resolution
39+
- Batched field resolution (addressing N+1 query problems)
40+
- A resolution plugin system supporting further extensibility
41+
42+
### Idiomatic Documents, Idiomatic Code
43+
44+
Write your schemas in idiomatic Elixir `snake_case` notation. Absinthe can
45+
transparently translate to `camelCase` notation for your API clients.
46+
47+
Or, define your own translation scheme by writing an simple adapter.
48+
49+
### Frontend Support
50+
51+
We care about support for third-party frameworks, both on the back and
52+
front end.
53+
54+
So far, we include specialized support for Phoenix and Plug on the backend,
55+
and [Relay](https://facebook.github.io/relay/) on the frontend.
56+
57+
Of course we work out of the box with other frontend frameworks and GraphQL
58+
clients, too.
59+
60+
### An Active Community
61+
62+
The project is under constant improvement by a growing list of contributors,
63+
and your feedback is important. Please
64+
[join us](http://absinthe-graphql.org/community/)!
4065

4166
## Installation
4267

4368
Install from [Hex.pm](https://hex.pm/packages/absinthe):
4469

4570
```elixir
4671
def deps do
47-
[{:absinthe, "~> 1.1.0"}]
72+
[{:absinthe, "~> 1.2.0"}]
4873
end
4974
```
5075

@@ -56,7 +81,7 @@ def application do
5681
end
5782
```
5883

59-
Note: Absinthe requires Elixir 1.2 or higher.
84+
Note: Absinthe requires Elixir 1.3 or higher.
6085

6186
## Upgrading
6287

0 commit comments

Comments
 (0)