Comments (10)
@jaydenwindle I'm a bit opposed to that, to be honest, there were some talks of merging some of the libraries back to the graphene repo. For example, if we do changes to strawberry "core" we need to update all the other packages probably.
For dependencies we could do something like:
pip install strawberry[django]
or even have a metapackage that does that for you:
pip install strawberry-django
:)
from strawberry.
Yes totally! I'd love to see this happen (I'd love to use strawberry for some Django side project I have).
I'm currently focused on finishing ASGI support (mainly adding tests and a better structure of the code), would you like to work on this? :)
from strawberry.
I'd love to work on this! I'll throw up some PRs in the next couple of days :)
from strawberry.
I've been giving this some thought, and I think that Django support would make more sense as it's own package (similar to how Graphene is set up). That way we don't have to worry about managing extra dependencies or releasing changes to strawberry that affect only the Django package.
I'll spin up a repo with the Django extensions and we can add it to the strawberry org when it's ready to release.
from strawberry.
Oh interesting - I didn't know there were discussions around that in Graphene. In that case I'll add it directly to this repo :)
from strawberry.
@jaydenwindle :) thanks!
Hopefully it won't be a bad idea!
from strawberry.
Would love to see this!
from strawberry.
Hi @patrick91! Does Django support at this stage also imply the automatic conversion of a QuerySet into the dataclass-like structure that Strawberry uses? So a resolver can return a model instance or a QuerySet, and this is converted to the appropriate type and handled accordingly by GraphQL.
from strawberry.
@Rocamonde so, we don't do any implicit conversion, but duck typing works. If you return anything that looks like the GraphQL type then things work :)
So for example this works:
@strawberry.type
class Query:
@strawberry.field
def user(self) -> User:
return models.User.objects.last()
we don't check what type is being returned in the resolvers. So this works, and works for lists too.
I think the only place where this doesn't work is Union types, because we need to understand what type we are returning (but we can find a work around for that).
We do this a lot in PyCon Italia's website: https://github.com/pythonitalia/pycon/blob/master/backend/api/conferences/types.py#L127-L155
Hope this helps :)
from strawberry.
I have been missing django model integration so I started to prototype this feature. Please try and leave feedback. https://github.com/la4de/strawberry-graphql-django
There is sample projects which can be used for testing as well. https://github.com/la4de/strawberry-graphql-django/tree/main/examples/django
from strawberry.
Related Issues (20)
- Expore schema directives in schema introspection API HOT 1
- Pyright 1.1.344 reports that a `strawberry.scalar(...)` variable cannot be used for return type annotation HOT 1
- Support Private Fields with Default Fields
- Subscription is not working with permission_classes HOT 3
- `MaskErrors` does not mask validation errors HOT 4
- Unable to disable graphiql by graphql_ide=None HOT 7
- django hits DB twice when it accesses a cached_property field. (A django field with @cached_property decorator.) HOT 6
- root Query type doesn't initialize fields correctly, fields with default_factory are unininitialized HOT 1
- Do I need `= None` for `Optional` fields in Strawberry types? HOT 1
- How to add support to dataloader in a sync code which executes in aws lambda?
- Schema visibility filters
- Different contexts getters depending on the query or mutation HOT 2
- When i use run with python3, ImportError occured HOT 5
- Customization of process_result in Channels integration doesn't work. HOT 1
- Support for Relay VSCode 2.1.0 pathToLocateCommand command
- Private fields not private in Python 3.12. HOT 5
- Deprecate starlite
- intermittent AssertionError from applying NodeExtension to the same field twice HOT 4
- "Getting Started" instructions resulting in a "Not Found" when accessing GraphiQL HOT 4
- Allow access to StrawberryField.metadata in a query level. HOT 15
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 strawberry.