Why Liferay APIs are awesome

Slides and code for Liferay's /dev/24 talk by Javier Gamarra.

The idea is to a simple TikTok clone like this:

-> Tested in 7.3 but Headless code is backported to 7.2 and 7.1.

How to install

  1. Launch your Liferay instance
  2. Clone this repo and launch npm i
  3. Run npm start and Play! :)

Steps

  1. Learn the existing APIs with /o/api && /o/openapi and the documentation
  2. Show and create GIFs with the REST APIs
  3. Use GraphQL
    1. Installing Apollo: npm install @apollo/client graphql
    2. Create an Apollo client
    3. Use useQuery
  4. Embed image with NestedFields & 'data:video/mp4;base64,'
  5. Conditionally render elements of the UI based on backend permissions with actions
  6. Store and retrieve documents and web contents in the new Asset libraries
  7. Return any asset with ContentElements API
  8. Transform your results with filter, search, sort and flatten
  9. Return or create all translations & window.navigator.language from chrome://settings/languages#lang
  10. Aggregate information with facets
  11. Improve performance -> fields && restrictFields
  12. Disable endpoints in headless settings
  13. Add new fields using WebContent or RelatedContents or CustomFields -> API extensibility
  14. Let's define our API, REST Builder

Things we have to mention!

  1. Batch framework
  2. More GraphQL relationships (children, parent, element)
  3. Headless Admin Content
  4. APIs: New APIs or improvements: document types & metadata, navigation menus, move documents...
  5. Vulcan: Automatic transactions, contextProviders, Bean Validation, Multipart...
  6. REST Builder: Permissions endpoints (& ViewableBy)
  7. Headless: Many more things... Java client, versioned GraphQL endpoint...

What's in the future?

Remember that you don't have to wait for 7.4, we do rolling releases!

  • New identifier for APIs
  • Webhooks
  • Server side events/GraphQL subscriptions
  • Layouts/Pages API
  • Admin APIs
  • Lazy fields
  • YOUR IDEA

Questions?

  • ...
  • ...
  • ...

Common questions?

  • How do I filter? -> see here. OData syntax is complex, so ask us in the community slack.
  • Liferay API Versioning? -> we won't break (again, sorry) the existing APIs at least until 7.4.
  • Auth, if I'm serving the application outside Liferay? -> same as Liferay Portal, whatever you are using there like OAuth, Basic Auth, Session, but recommended is OAuth.
  • Service Access Quotas? -> interesting, ping us! (you can use an API Gateway but we can talk).
  • CORS? -> yeah, default for GraphQL but has to be configured for APIs. Remember/understand what CORS is or should: a configuration only for development because you are using different IPs in a browser request. Doesn't apply if we serve portlets, and it's a dev issue, should not be a production issue.

Links

Thanks

  • TikTok React template from CleverProgrammers
  • Sample videos from Vertical Video: Current State of the Art
  • Sample TikToks by:
    • malinoisdog, "Like watching the plot, still like watching me fly #dog #fly #fyp", Wrecking Ball(fast ver.) - Miley Cyrus
    • charlidamelio, "THANK YOU ALL SO SO SO MUCH FOR 86 MILLION!!!! @mishagabriel @rexkline @breakthefloor", Move Ya Hips - A$AP Ferg
    • guille_what, "¿Cuantos metros crees que son?🚀", Obnimi - Callmearco Remix - mattia
    • thesupercole, "Savannah might’ve gone into labor making this...🤰🏼 ", Love Story Discolines - EthanIsHung
    • youneszarou, "Is this insane? #yzfamily #foryoupage #fürdich #fyp", Still Don't Know My Name - Labrinth