Does relay.NodeField support many args more than "id" ?
See original GitHub issueHi, guys
In graphene/relay/fields.py
:
class NodeField(Field):
# ...
def id_fetcher(self, global_id, info):
# ...
return object_type.get_node(_id, info)
def resolver(self, instance, args, info):
global_id = args.get('id')
return self.id_fetcher(global_id, info)
This define a get_node
strictly, just global id could be used as arg.
There is an example about other scene:
http://graphql-swapi.parseapp.com
They define a more useful interface:
film(id: ID, filmID: ID): Film
person(id: ID, personID: ID): Person
planet(id: ID, planetID: ID): Planet
species(id: ID, speciesID: ID): Species
starship(id: ID, starshipID: ID): Starship
vehicle(id: ID, vehicleID: ID): Vehicle
node(id: ID!): Node
It has a ‘XXXID’ arg in every node field. This is just what I wanted. It would be useful where a NodeField
can queried by other args not just id.
Any help would be appreciated. Thanks!
Refs:
Issue Analytics
- State:
- Created 8 years ago
- Reactions:4
- Comments:5 (3 by maintainers)
Top Results From Across the Web
GraphQL Global Object Identification Specification - Relay
The server must provide an interface called Node . That interface must include exactly one field, called id that returns a non-null ID...
Read more >Extending query arguments in graphene/graphene_django
The answer turns out to be simple. To add arguments to the resolver, declare the arguments in the constructor of the field, like...
Read more >How to implement a nodes type with IDs args in absinthe?
Yes, ben. Thanks for your work. Implementing a node interface when use Absinthe.Relay.Node is very easy, but I'm asking how to implement a...
Read more >GraphQL: understanding node interface. - DEV Community
NOTE: If two objects appear in the query, both implementing the Node with identical ids, then the two objects must be equal. Node...
Read more >Key arguments in Apollo Client - Apollo GraphQL Docs
The Apollo Client cache can store multiple entries for a single schema field. By default, each entry corresponds to a different set of...
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 Free
Top 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
I made something for same need:
In related query, it should be used as
Old interface:
film(id: ID!): FilmNode
New interface:film(id: ID, slug: String): FilmNode
As @mjtamlyn commented, this will be probably not implemented in
graphene.relay
as is not in the relay spec.Closing this issue.