Comments (5)
@femesq Sure, that makes sense. Anything that would add/modify/delete data is grounds for a triggered event, but there's a key distinction to be made here, which is that if you place the trigger event on a mutation, then if I understand you, that means that only mutations that happen through GraphQL will trigger that event. That means things like the django admin, or command line scripts that may run (scheduled cron jobs or other events), unless those are all modified to use graphql, will not cause the event to happen.
If, on the other hand, the event happens post-save on the model, then as long as the django ORM was involved, it will trigger.
re: permissions, I wasn't actually suggesting this was a problem, but it's a situation where an example would be useful. The important thing here is to not tie permissions too closely to the framework. It should be up to developer how they want to check for permissions, but we want an example that's beyond "broadcast to everyone".
from graphene.
How does this work? How do you trigger a push from the server? The way I understand the commit is that this is just the subscription part and I have to manually implement a pub-sub, am I right?
from graphene.
👍
from graphene.
@lightning18 The standard doesn't explicitly say when a trigger happens, only that the client may request a subscription. I would guess that then 'when' question would be something that would be something related to a signal on a given object in a post-save.
I'd guess that the right way to handle this is to require the use of django-channels (https://github.com/django/channels/) and then place a request to update the clients on the appropriate channel bus.
I'm less sure how to do this in an agnostic way- maybe the right thing to do isn't to explicitly say that graphene-django must support this, but instead to provide a documentation example of how to implement it, both for the general case of a simple notification, but also to show how (as per the GraphQL spec) there needs to be authentication support- ie a user should only get notified of a subscription to which they have proper permissions.
from graphene.
I'm joining the conversation 'cause I'm interested in this topic.
@KinkyVirCotto:
Most of the talks I saw, make use of examples that fires subscription when a mutation happens... But yes: that could happen on DB's post-save if data-mutation can happen other places too..
About the permission, that could be solved my checking the permission on subscription
request. In case the user don't have access to receive such updates, the query could return an 'false' flag on a "success" field, or return null
on fields values..
from graphene.
Related Issues (20)
- `graphql_schema` introspection doesn't output docstrings descriptions
- InputObjectType causing encoding issues with JSONField HOT 1
- @include and @skip directives lead to irrelevant errors HOT 2
- Provide a way to configure default timezone of DateTimes HOT 3
- Turning Non-null to is_null HOT 3
- Enum conversion to Graphene Enum fails if Enum name is "type" HOT 1
- Enum equality comparison is inconsistent
- http://www.graphene-python.org Has EXPIRED HOT 3
- Upload file HOT 2
- Unexpected argument in Pycharm 2023.2.1 HOT 1
- Default_value option in Arguments inside Mutation is not working as expected HOT 2
- Exception: NonNull could not have a mounted String() as inner type. Try with NonNull(String).
- Returning non fatal errors alongside data HOT 1
- Conversion to snake_case fails on nested inputs
- Depth limit validator key error if fragment undefined
- Tests in `graphene/relay/tests/test_custom_global_id.py` fail due incompatibility with pytest 8.x HOT 2
- Enum.from_enum() fails with Django IntegerChoices
- Do you support GQL over websocket? HOT 1
- More documentation for DisableIntrospection?
- Subclass built-in scalars without creating new GraphQL type
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphene.