Skip to content

Add Mercure support in React and React Native generators + various improvements #94

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

Merged
merged 1 commit into from
Nov 9, 2018

Conversation

dunglas
Copy link
Member

@dunglas dunglas commented Nov 8, 2018

Q A
Bug fix? yes
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets n/a
License MIT
Doc PR api-platform/docs#648

A short video showcasing the features added by this PR:

gif

Full (high quality) video: https://www.youtube.com/watch?v=UI1l0JOjLeI

As you can see, these React (web) and React Native (mobile) apps are automatically updated when the data is changed server-side. Under the hood, they use the Mercure protocol.

The 2 apps shown in this video have been generated directly from the API documentation of the API Platform's demo (with this PR that enables the server-side Mercure integration).
Not a single line of code has been changed for the recording!

Basically, to generate similar apps from an API you just have to run:

# React
npx @api-platform/client-generator https://demo.api-platform.com src/
# React Native
npx @api-platform/client-generator https://demo.api-platform.com . -g react-native

Detailed changelog:

  • Add support for real time updates using Mercure to the React and React Native generators. Works perfectly well with Automatically dispatch updates to clients using the Mercure protocol core#2282.
  • Add support for to-many relations (React only, not tested with React Native)
  • Fix how links are generated (the previous solution was subject to false positive)
  • Bump all dependencies
  • Upgrade from react-router-redux (deprecated) to connected-react-router
  • Improve and simplify the generated code
  • Make the generated code following Prettier CS
  • Fix CS of the tool itself

The documentation has also been updated to be more accurate, and now includes screenshots!

(sorry for the big PR, but it was easier to do everything in one batch)

@mysiar
Copy link
Member

mysiar commented Nov 9, 2018

It is all great, just one question before the merge though.
Would it work with API without Mercure protocol implemented ?

@dunglas
Copy link
Member Author

dunglas commented Nov 9, 2018

If it's not implemented, it works as before, but there are no live updates (obviously).

@mysiar
Copy link
Member

mysiar commented Nov 9, 2018

If it's not implemented, it works as before

this is what I was actually asking for 👍

@mysiar mysiar merged commit 36cd069 into api-platform:master Nov 9, 2018
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.

2 participants