2

api-platform automatically issues events to a mercure hub when updating resources marked with mercure=true and publishes the topics to listen on in the according GET endpoints. Nice. Is there already an option that I can use in the generated GraphQL endpoints?

The mercure docs say: https://github.com/dunglas/mercure#how-to-use-mercure-with-graphql that mercure should integrate "very well" with any GraphQL API as long as it "returns a corresponding topic URL". But afaik the GraphQL API generated by api-platform doesn't (https://api-platform.com/docs/core/mercure/). Do I miss anything or is this upcoming? Using apollo-vue on the frontend.

To work around I could listen to changes on all entity ids using dedicated EventSource topics on the frontend. I would use an URI template like http://localhost:8080/product_streams/{id} there. But I can't manage to write an uri template that matches only certain ids like: http://localhost:8080/product_streams/{id:123,456,789} to get only updates for streams no 123 456 789 (tried https://uri-template-tester.mercure.rocks/ && https://www.rfc-editor.org/rfc/rfc6570#page-18) with no success :(

Community
  • 1
  • 1
Stefan
  • 3,382
  • 4
  • 23
  • 27

1 Answers1

1

Edit: GraphQL subscriptions are now supported by API Platform. Checkout the documentation: https://api-platform.com/docs/master/core/graphql/#subscriptions

API Platform doesn't support GraphQL subscriptions yet. Adding support for subscriptions using Mercure (that is designed among other things for this use case) is planned, but the work hasn't started yet. Any help is welcome!

Kévin Dunglas
  • 2,864
  • 2
  • 23
  • 39