Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.x] REST API support #356

Merged
merged 30 commits into from
Nov 11, 2023

Conversation

ryanmitchell
Copy link
Contributor

@ryanmitchell ryanmitchell commented Nov 3, 2023

This PR brings REST Api support to Runway.

Ensure the API is enabled, then opt into any resources you want in statamic.api.resources under a runway key:

'resources' => [
    'collections' => true,
    'navs' => false,
    'taxonomies' => false,
    'assets' => false,
    'globals' => true,
    'forms' => false,
    'users' => false,
    'runway' => [
        'users' => ['allowed_filters' => ['name']],
    ],
],

Then your resource list should be available at /api/runway/{resource}

To do:

  • Tests
  • Ensure model key is in the returned fields
  • Write documentation

@ryanmitchell ryanmitchell changed the title REST API support [6.x] REST API support Nov 3, 2023
@ryanmitchell ryanmitchell changed the base branch from 5.x to 6.x November 4, 2023 17:45
@duncanmcclean duncanmcclean changed the title [6.x] REST API support REST API support Nov 6, 2023
@duncanmcclean duncanmcclean changed the title REST API support [6.x] REST API support Nov 6, 2023
Copy link
Member

@duncanmcclean duncanmcclean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I've noticed is that nested fields (those inside JSON columns) don't seem to work. Although, this may be unrelated to anything in this PR.

CleanShot 2023-11-06 at 20 13 54

Ideally, we'd have a metadata object, which inside it would have alternative_title, publish_date, related_entries.

@ryanmitchell
Copy link
Contributor Author

Not sure that's related to this PR. I'm using toAugmentedArray in the api resource so maybe it's something there?

@ryanmitchell ryanmitchell marked this pull request as ready for review November 7, 2023 08:03
@duncanmcclean
Copy link
Member

I'll try and carve out some time over the next week to give this a proper review - thanks for your work on this! 🙌

I noticed that a BelongsTo field in my resource blueprint is causing an infinite loop when visiting the endpoint. That's probably something for me to figure out (may involve going back to shallow augmentation) 😅

Copy link
Member

@duncanmcclean duncanmcclean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work on this! 🙌

I've made a couple of nit-picky tweaks and fixed the issues I was having with nested fields & "BelongsTo" fields.

@duncanmcclean duncanmcclean mentioned this pull request Nov 11, 2023
@duncanmcclean duncanmcclean merged commit aff1fd4 into statamic-rad-pack:6.x Nov 11, 2023
6 checks passed
@ryanmitchell ryanmitchell deleted the feature/rest-api branch November 12, 2023 09:12
Copy link

Released as part of v6.0.0.

1 similar comment
Copy link

Released as part of v6.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants