All notable changes to
the @dillonkearns/elm-graphql
npm package
will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
- Handle generating possible types to select in interfaces in some cases, see #608. Thank you @th3coop for the fix!
- Deprecated fields now include an
@deprecated
message within the doc comment for the generated function. See #600. Thank you @gampleman for the PR!
- New
--skip-validations
flag to avoid runningelm make
to give more precise validation errors for Scalar Codecs module if users want to avoid the extra execution time or the additionalelm make
step.
- Improve validation error message for
--scalar-codecs
CLI option (see #576). Thank you for the PR @ZeldaIV!
- Use unqualified reference to
Basics.identity
to avoid naming conflicts in generated code. That means user-defined GraphQL fields can have the nameidentity
without causing any Elm compiler errors now.
- The input object loop detection had some false positives. This fix prevents using nested input object loop wrappers for some deeply nested input objects that are actually not circular. See #475. Thank you @mcasper!
- Added long
_
suffix to generated parameter and let binding names to prevent any shadowing issues in generated code (see #457). - Don't require
npx
to runelm-format
. Instead,elm-graphql
will now look on the PATH to try to findelm-format
, and give an error message if it is not found. See #458.
- Node 10.12.0 is now the minimum supported Node version.
elm-graphql
now uses thefs
package directly from Node instead of usingfs-extra
. - Remove unused dependencies.
- Give Decoder errors instead of hanging on invalid types in some cases. Solves some of the cases. Others may be addressed in a future change by using more explicit and constrainted types. See #379.
- Fixed a bug with the ordering of nullable list encoders for input objects (see #456).
- Fixed issue with running
elm-tooling install
as apostinstall
script. This was supposed to run as part of the development tooling, not the published package. Fixed with these instructions.
- Fixed issue with
--header
options that had:
within the values, see #441. Thank you Jonas for the fix! - Updated NPM dependencies.
- Update
graphql
npm package to add support for parsing GraphQL Description syntax in schema files. Fixes #452.
- Updated to latest version of
graphql-request
NPM dependency, see #419. Thank you @Hermanverschooten!
- Generate type annotation for
Api.Scalar.unwrapEncoder
function.
- Use vertical formatting for function type annotations. Thanks to @sporto for the PR! See #351.
- Fixed CLI stalling when schema had field names with only
_
s (fixes #285). The generated field names will be prefixed withunderscore
(see details in #311).
- Suppressed Elm's compiled in dev mode warning, see #278. Thank you @jouderianjr!!!
--schema-file <schema-file>
option for CLI (thank you jouderianjr!). This allows you to directly point the CLI to a file with the GraphQL schema definition language (SDL) format, and it will generate code based on that schema. See #247.
- Fix typo in internal function name (
exhuastiveFragmentSelection
->exhaustiveFragmentSelection
).
- Reduce NPM bundle size by removing
.npmignore
file and adding explicitfiles
whitelist topackage.json
.
- Fixed error when running CLI (#150) that was caused by an issue with the parcel build step. The Travis continuous integration build script is now running a more realistic check that will avoid issues like this slipping through into the published binaries in the future (NPM versions are only published after a green build). See the issue for more details.
- Fixed #138. Before this fix, an input object would incorrectly use a Custom Type wrapper instead of a plain record type alias to avoid circular dependencies in a case where there was no circular dependency. Thank you @mattdb for reporting the issue, and providing a minimal failing test case! 🙏
Just some changes under the hood.
- Update to latest npm dependencies. Note that the latest elm npm package doesn't change the elm version, just the npm asset. It's still just elm 0.19.
- Use parcel for bundling, and minify the
elm-graphql
npm binary. The behavior should be exactly the same, and the extensive automated tests check out, plus my manual testing of the binary.
- Don't use field aliases for __typename fields (see PR #121).
- Generate
fromString
for Enums. This function is the inverse of the EnumtoString
helper. SoNewHope |> Episode.toString |> Episode.fromString == Just NewHope
.
- The code now for the scalar codecs file includes custom Encoders (not just Decoders). Before this, you would get an error if you tried to use custom decoders but your Custom Scalar was passed somewhere as an argument (see #109).
- Renamed
--scalar-decoders
flag to--scalar-codecs
.
- New
--scalar-decoders
flag allows you to define your scalar decoders in a custom module. See pull request #101.
- This change doesn't require any modifications to user code. Simply re-run the latest CLI and upgrade to the latest Elm package and you'll be good to go! See the 3.0.0 Elm package changelog for implementation details about this change.
- The code generate has changed to completely remove the
Field
module. See the Elm package version 2.0.0 release notes for details and migration steps.
- Now using
--optimize
flag so there is no more warning printed from Elm when running the CLI. - Now using https://github.com/dillonkearns/elm-cli-options-parser so you will get better feedback when you pass invalid arguments to the CLI.
- Only run
elm-format
on the generated code directory, not the entire
--output
directory. In the last release, it didn't take--base
into account when runningelm-format
.
- Add newlines for readability in the generated code between fields in type alias definitions. See #74 for details.
- This introduces a backwards-incompatible change for any selections on Unions or Interfaces. The change allows you to do exhaustive type-specific fragments. Now, if you add a new type to a Union or Interface in your schema, the Elm compiler will tell you to check for that type if you're doing an exhaustive selection. See this diff to understand the changes and how to migrate to the new version: e530d94.
- With the new change, you can build exhaustive type-specific fragments that get rid of the Maybe (because the compiler knows you're handling all possibilities).
elm-format
failed to run during the code generation in some configurations. The new solution uses an NPM peer dependency ofelm-format
. That means that it will make you install it if it's not already in your dependencies in yourpackage.json
. With that as a local dependency, we can safely callnpx
to run your local elm-format version. Note that this requiresnpm >= 5.2.0
. See #87 and #91 for more details.- The
elm-format
binary was previously run for each individual file asynchronously, which could cause performance issues in some environments. Now,elm-format
is run as a single step on the entire generated directory after files are generated. This is more performant and more reliable.
- Add explicit
elm-version=0.19
argument when runningelm-format
in order to fix #79.
- Generate a list of all possible enums for each enum module. Adds #77.
- There was a missing import for schemas which referenced the root query/mutation/subscription objects. This came up with schemas generated by Graphile (though it may have effected other schemas as well). This resolves #78.
Nothing to see here! Release 1.0.4 was just testing out a new Travis npm deploy script.
- Use extracted
scalarDecoder
constant fromdillonkearns/elm-graphql
package. This change allows us to remove allDebug.toString
calls in generated code so that users can compile their code with the--optimize
flag. This resolves #68.
- Generate code for
dillonkearns/elm-graphql
. This requires Elm version 0.19. - If you are upgrading to Elm 0.19 follow the
dillonkearns/elm-graphql
0.19 upgrade guide. You can see more details of what's changed in the Elm package changelog.
BELOW THIS IS FOR the npm graphqelm
package (elm packagedillonkearns/graphqelm
). Read more about the rename to dillonkearns/elm-graphql
.
- Fix #55. Encoding was incorrect for Elm reserved words because it was incorrectly normalizing input object keys when it should have used the raw keys.
- Fix code generation for constructors for circular input objects.
Previously,
build<InputObject>
returned records without wrapping them in their type constructors when needed. This worked for plain type aliases but not for the types for self-referential input object types. The code generation is now correct for both of these types.
- Generate
build<InputObject>
constructor functions (#49).
- Fixed
RangeError: Maximum call stack size exceeded
that was coming from infinite recursion CLI bug, issue #47.
- Add
--introspection-file
CLI option to usage message.
- Normalize all Elm reserved words by appending an
_
(previously onlytype
was normalized). Resolves #40 (thanks for pull request #41 @madsflensted!).
- Import all
Operation
values (it's rare but possible for schemas to refer to other operations) #45.
- Add maybe encoder to pipeline for nullable scalar encoders. Fixes #44.
- Fix infinite loop when checking for circular InputObject defs. This resolves issue #47 (the CLI was crashing for graph.cool endpoints).
- Generate type alias for required args to make it easier to annotate consumer code. Fixes #31.
- Add support for non-string scalars, fixes issue #37.
- Use
Decode.nullable
rather thanDecode.maybe
so that decode failures don't incorrectly get swallowed into aNothing
values but rather bubble up asErr
Results
.
- Generate type alias for optional args to make it easier to annotate consumer code.
- Include type alias for records in the union type for Input Objects with loops. This allows for nicer annotations in consumer code.
- Generate wrapped record union type for Input Objects with loop (recursive or circular references), and plain type alias for Input Objects with no loop.
- Fix issue with type generation for InputObject type aliases that contain a List type.
- Generate InputObjects as types (not type aliases) inside a single file to allow for recursive or circular input types.
- Add log statements to show progress while running CLI.
- Include deprecated fields by default. Add
--excludeDeprecated
CLI flag in place of--includeDeprecated
.
- Generate special module for Subscriptions.
- Renamed type variables from
selection
todecodesTo
for clarity. - Updated code generation to use type and module name
Field
rather thanFieldDecoder
for elm package version 7.0.0.
- Single-letter names no longer cause exceptions (like
x
ory
).
- Update name normalization strategy to make only the minimal change to make a name valid (that is, put leading underscores at the tail, and make sure the first letter is the correct case). Unless it is ALL_UPPERCASE_UNDERSCORE_SEPARATED_NAME, then make it ClassCase.
- Generate metadata json file with target elm package version and npm package version.
- Remove npm version number and target elm package version number from comments on generated modules to reduce diff noise in future updates.
- Fixed error on windows related to shelling out.
- Stopped generating unnecessary InputObject type definitions file.
- Add
--output
flag to command line to choose a directory other than./src
for generated output - Support intropsection json files with no top-level
data
json key.
- Generate Scalars module with type definitions/constructors for each custom scalar.
- Experimental
--introspection-file
flag to allow users to pass in a file with the result of the introspection query. This may change in the future.
- Generate InputObject modules for type-safe input objects.