Commit graph

358 commits

Author SHA1 Message Date
Zach Daniel
896d76420b fix: accepted attributes don't have to be public? 2024-05-11 18:25:23 -04:00
Zach Daniel
761a60f3b4 chore: add an experimental auto_import_types? option to use AshGraphql
this is to solve a very specific technical issue around conflicts with
using `import_types` on your schema, and having conflicts with a named type
you already have defined, and the types we import
2024-05-11 18:24:58 -04:00
Alan Heywood
7386a5b627
improvement: make mutation result errors list non-nullable (#144)
* chore: regenerate cheat sheets

* improvement: make mutation result errors list non-nullable
2024-05-03 21:57:02 -04:00
Josh Price
c015030dc5
docs: minor doc updates (#142) 2024-05-01 16:45:20 -04:00
Zach Daniel
0e79680681 docs: documentation overhaul 2024-05-01 15:59:38 -04:00
Riccardo Binetti
833c1d5143
feat: allow passing custom descriptions to queries and mutations (#138)
Close #137
2024-04-29 15:01:26 -04:00
Zach Daniel
019632c420 fix: properly set actor on bulk action calls 2024-04-27 09:27:00 -04:00
Zach Daniel
fb74c2a4f3 improvement: use bulk actions for create/destroy 2024-04-25 23:28:37 -04:00
Zach Daniel
84b86e65be improvement: add graphql_define_type?/1 callback for graphql types 2024-04-24 09:21:26 -04:00
Zach Daniel
4c0ed1160c chore: fix credo warning 2024-04-24 09:00:56 -04:00
Zach Daniel
e60c0def27 fix: don't process maps with no fields 2024-04-24 08:49:53 -04:00
Zach Daniel
ee43ec4a26 fix: tag union values with their type before casting 2024-04-23 19:54:00 -04:00
dependabot[bot]
df04981d49
chore(deps): bump ash from 3.0.0-rc.6 to 3.0.0-rc.18 (#127)
* chore(deps): bump ash from 3.0.0-rc.6 to 3.0.0-rc.18

Bumps [ash](https://github.com/ash-project/ash) from 3.0.0-rc.6 to 3.0.0-rc.18.
- [Changelog](https://github.com/ash-project/ash/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ash-project/ash/compare/v3.0.0-rc.6...v3.0.0-rc.18)

---
updated-dependencies:
- dependency-name: ash
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: Fix dialyzer error.

`action.accept` can no longer ever be `nil`.

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: James Harton <james@harton.nz>
2024-04-22 09:31:33 +12:00
Zach Daniel
bd9562a9fa fix: ensure type is set when using find_manage_relationship
closes #132
2024-04-20 16:24:05 +01:00
Zach Daniel
1c4cf1969c fix: properly honor new pagination config everywhere
fixes #130
2024-04-20 16:18:52 +01:00
Zach Daniel
1331bdd4ce improvement: support generic actions with no return type 2024-04-11 13:11:37 -04:00
Zach Daniel
10fa6b2ff7 chore: format 2024-04-04 21:45:33 -04:00
Zach Daniel
2552f07689 fix: accept input object for destroy mutations 2024-04-03 10:19:13 -04:00
Zach Daniel
d692c931c2 chore: format 2024-04-01 16:16:05 -04:00
Zach Daniel
180d05545c improvement!: auto? managed_relationships by default
imporovement!: remove deprecated configuration
2024-04-01 16:02:30 -04:00
Zach Daniel
349086fbb8 improvement!: No longer automagically derive types 2024-04-01 15:27:43 -04:00
Zach Daniel
78c5b6a3bb chore: update errors and deps 2024-04-01 14:13:48 -04:00
Riccardo Binetti
513c1ac68f
improvement!: port AshGraphql to Ash 3.0 (#123)
Step 1: update Ash

Step 2: mass rename Api to Domain

Step 3: Ash.Query.expr -> Ash.Expr.expr

Also change ref interpolation

Step 4: remove all warnings

Step 5: remove registries from tests

Step 6: fix filter

Step 7: private? -> !public?

Step 8: Ash.Calculation -> Ash.Resource.Calculation

Step 9: use depend_on_resources/1 -> resources/1

Step 10: add Domain to all resources

Step 11: use Ash module for all actions

Step 12: add public? true all around

Step 13: remove verbose? from options passed during Domain calls

Step 14: add simple_sat

Step 15: Ash.ErrorKind is no more, so remove code from errors

Step 16: sprinkle default_accept :* around tests

Step 17: replace Ash.Changeset.new/2 with Ash.Changeset.for_*

Step 18: calculation fixups

- Context is now a struct and arguments go under the arguments key
- Function based calculations receive a list of records
- Add a select to query-based loads
- select -> load

Step 19: pass the correct name to pass the policy in tests

Step 20: Ash.Query.new/2 is no more

Step 21: add AshGraphql.Resource.embedded? utility function

Use that instead of Ash.Type.embedded_type?(resource_or_type) since resources
are not types anymore

Step 22: handle struct + instance_of: Resource in unions

Resources are not type anymore so they need to be passed this way in unions

Step 23: ensure we only check GraphQL actions for pagination

All reads are now paginated by default, so this triggered a compilation error

Step 24: swap arguments for sort on calculations

Step 25: remove unused debug? option
2024-04-01 14:03:06 -04:00
Riccardo Binetti
9674614b62
feat: allow resources without types (#121)
* fix: regenerate spark formatter and cheatsheet

Make CI pass again

* feat: allow resources without types

Ensure they only expose generic action queries. Add checks to ensure that either
`type :resource_type` or `generate_object? false` is passed if it's needed.

Close #119
2024-03-28 11:16:32 -04:00
Dmitry Maganov
1f2358ef68
improvement: add show_fields option as explicit fields whitelist (#120) 2024-03-27 14:54:58 -04:00
Riccardo Binetti
98baf6f0be
feat: allow providing descriptions for enum values (#117)
* chore: update ash to use Ash.Type.Enum descriptions

Contextually, remove an unreachable clause that caused dyalizer to fail,
see https://github.com/ash-project/ash/pull/873 for the commit that made
it unreachable

* feat: allow providing descriptions for enum values

If the module exports `graphql_describe_enum_value/1`, use that. Otherwise,
fallback to the Ash.Type.Enum value descriptions introduced in
https://github.com/ash-project/ash/pull/940.

Close #116
2024-03-25 23:43:59 -04:00
Riccardo Binetti
1c47c79081
chore: fix CI failures (#118)
* chore: regenerate formatter and cheatsheets for paginate_with

* chore: fix credo errors

Use pattern matching to remove an if level and invert the logic on the
if Credo was complaining about
2024-03-22 12:59:21 -04:00
Zach Daniel
51004afa8d fix: include generic actions in enum filtering 2024-03-14 23:09:44 -04:00
Zach Daniel
ae94fcde54 improvement: make pagination more explicitly configurable 2024-03-13 12:10:30 -04:00
Zach Daniel
d2343e5c54 chore: credo/remove inspects 2024-03-11 10:48:44 -04:00
Zach Daniel
90dc20822d improvement: add hide_inputs to queries and mutations 2024-03-11 10:46:42 -04:00
Zach Daniel
99d2d66538 chore: change is_node_type/1 to node_type?/1 per credo 2024-02-11 14:44:31 -05:00
Zach Daniel
22034fd47a chore: credo 2024-02-11 14:41:24 -05:00
Zach Daniel
328618fa94 fix: handle unions containing maps and vice versa 2024-02-11 14:10:20 -05:00
Riccardo Binetti
70eae5f421
fix: make results nullable again if root level errors are enabled (#114)
Building upon #110, this restores the old behaviour of the result being nullable
when root level errors are present.

While the result is guaranteed to not be nullable in standard conditions (since
either result or errors are always present), when errors are moved to the root
level it could become null, so declaring it non-nullable propagates the null up
to the data field.

This actually causes compatibility problems with some client libraries (e.g.
Relay) that expect the inner result to be null, _not_ data, if there's an error.

This also adds dedicated RootLevelErrors versions of the Api and the Schema
since the configuration is accessed at compile time now, so put_env was not
enough to test them correctly.
2024-02-09 09:36:23 -05:00
Barnabas Jovanovics
c82512d70a
* improvement: support data layer functions (ilike, like) (#113)
---------

Co-authored-by: Zach Daniel <zach@zachdaniel.dev>
2024-02-09 09:03:10 -05:00
Riccardo Binetti
66d2f44443
feat: add Relay ID translation in mutation and queries (#109)
Adds a new option for queries and mutations that defines which arguments or
attributes will use a global Relay ID and their type. This allows automatically
decoding them before hitting their action.

This paves the way to automatic translation derived from the arguments, which
will be implemented subsequently.

---------

Co-authored-by: Zach Daniel <zachary.s.daniel@gmail.com>
2024-02-06 09:46:09 -05:00
Zach Daniel
d00ae4e315 fix: define map input types w/ nested input types 2024-02-05 13:48:22 -05:00
Zach Daniel
099540c79e fix: handle nested constraint derivation in union/map types 2024-02-04 10:36:23 -05:00
Riccardo Binetti
6b09e7309e
improvement: make the items of fields and errors non-null (#112)
Last point left from the discussion on #105
2024-01-31 17:52:33 -05:00
Riccardo Binetti
8fff0d361d
improvement: make mutation arguments non-null (#111)
* improvement: make mutation arguments non-null

As discussed in #105 and #110, put this behind an opt-in configuration to avoid
breaking existing code.
The ID in update mutations is always non-null if non-null mutation arguments are
allowed, while input is non-null if it's allowed _and_ there is at least a
non-null field in the input.

Document the newly added config variable in the getting started guide.

* chore: enable non-null mutation arguments in tests
2024-01-31 17:52:01 -05:00
Riccardo Binetti
af4193feca
improvement: make mutation results non-nullable (#110)
Adjust rool level error tests: since result is now non-nullable, if the content
of the result is nil, the whole result becomes nil. Note that this is not a
breaking change since GraphQL always allows a field nullability to propagate
upwards in case of a field error (see October 2021 spec, section 6.4.4).
2024-01-31 15:59:07 -05:00
Riccardo Binetti
afa4ae66a0
improvement: return a map from decode_relay_id/1 (#107)
Slight API improvement over #106.

This makes it more ergonomic to partially match on the return value (and it also
makes it more explicit by explicitly labeling the two parts).

Also add tests for relay id encoding/decoding.
2024-01-25 10:47:15 -05:00
Riccardo Binetti
365b3aedc6
feat: Relay refetching support (#106)
* feat: add support for relay global IDs

* improvement: use the GraphQL type when projecting fields

This allows picking also up fields coming from fragments in queries returning an
interface

* feat: add relay node query

Allow retrieving a resource implementing the Node interface given its Relay
global id.
2024-01-24 14:59:12 -05:00
Zach Daniel
67fe4d64ec improvement: support latest ash 2024-01-19 00:13:39 -05:00
Zach Daniel
88aff4369d fix: properly transform not found errors 2023-12-05 16:44:21 -05:00
Zach Daniel
f83c447267 fix: respond with proper error on not found for get 2023-12-05 16:07:07 -05:00
Zach Daniel
51428483ef chore: raise error to help debugging 2023-12-05 15:32:47 -05:00
Zach Daniel
e16592f592 improvement: handle nil parent 2023-12-05 12:46:38 -05:00
Zach Daniel
c5163d4019 fix: fix dialyzer types for AshGraphql.Type 2023-12-04 18:29:30 -05:00