Document resolvers
See original GitHub issueI just learned, completely by accident, one of the most critically useful features of Graphene: resolvers can return anything, even for object resolvers! They don’t have to return instances of graphene.ObjectType. So, this works:
class TestInstance:
x = 1
y = 2
class Test(graphene.ObjectType):
x = graphene.Int()
y = graphene.Int()
class Query(graphene.ObjectType):
test = Test()
def resolve_test(self, info):
return TestInstance()
While this is hinted at in the ObjectType reference docs, there are no code examples of the pattern, nor documentation of any kind about the behavior of resolver functions. Documentation about this feature, and guidance about nested Objects, should be added.
I’m trying to draft something but I don’t have a lot of time these days so I wanted to file an issue just in case
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:18 (6 by maintainers)
Top Results From Across the Web
Resolvers - Apollo GraphQL Docs
To accomplish this, it uses resolvers. A resolver is a function that's responsible for populating the data for a single field in your...
Read more >About a Document Resolver Service
A document resolver service is a service that you create to perform duplicate detection for messages received by a JMS trigger or documents...
Read more >Resolvers – GraphQL Tools
Resolvers are per field functions that are given a parent object, arguments, and the execution context, and are responsible for returning a ...
Read more >Resolvers | Apple Developer Documentation
Resolvers let the system translate one type to another automatically. The system provides resolvers to convert between integer, floating-point, Boolean, string, ...
Read more >JavaScript resolvers overview - AWS AppSync
JavaScript resolvers overview for AWS AppSync. ... aws appsync evaluate-code \ --code file://code.js \ --function request \ --context file://context.json ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@altaurog yep I’ve come across this issue before with the
Node
type. The way we worked around it was to create our own customRelay.Node
type and use that everywhere instead. That then gives you the opportunity to define aresolve_type
method on the Node interface that can translate your underlying data structure into a Graphene type. E.g:Depends on how your data is modelled really. Using the ObjectType as a container for your data doesn’t provide any benefits really.