Skip to content

Commit

Permalink
Disable nested fields on GraphQL
Browse files Browse the repository at this point in the history
Currently, this won't work since GraphQL won't allow you to use `->` in field names.

I've looked at possible using something in place of `->` but couldn't figure out how to make it work, so I've left it for now.
  • Loading branch information
duncanmcclean committed Jul 26, 2023
1 parent 4ecb4f3 commit d39ea1f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ You may also run this same command for all resources:
php please runway:generate-blueprints
```

### Storing blueprint fields in a JSON column
### Nesting fields inside JSON columns

To avoid creating a migration for every new field you add to a blueprint, fields can be stored within a JSON column. To do so, use the `->` symbol within the field handle:

Expand All @@ -152,7 +152,7 @@ protected $casts = [
];
```

Please note generating a migration from a blueprint configured in this way is **not** currently supported.
> **Note:** Currently, Nested Fields aren't be available in GraphQL & aren't supported by the [migration generator](#generating-migrations-from-your-blueprints) command.
## Configuring resources

Expand Down
2 changes: 2 additions & 0 deletions src/GraphQL/ResourceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public function fields(): array
->mapWithKeys(fn ($value, $key) => [
Str::replace('_id', '', $key) => $value,
])
// TODO: Make nested fields work with GraphQL
->reject(fn ($value, $key) => str_contains($key, '->'))
->map(function ($arr) {
if (is_array($arr)) {
$arr['resolve'] ??= $this->resolver();
Expand Down

0 comments on commit d39ea1f

Please sign in to comment.