Retrieve authenticated user without supplying ID! when using relay
See original GitHub issueHi there! Thanks for the awesome library. I’m having a little problem I cant seem to find any documentation for. With a simple schema like this, I can ensure return the details for the authenticated user:
from django.contrib.auth import models
class UserType(DjangoObjectType):
class Meta:
model = models.User
class Query(ObjectType):
user = graphene.Field(UserType)
def resolve_user(self, args, context, info):
if context.user.is_authenticated:
return context.user
schema = graphene.Schema(query=Query)
So I can do a query like:
query {
user {
firstName
lastName
email
}
}
and it returns the details for the currently-logged in user (i.e. me).
Now I’d like to set it up for use with relay, so I do this:
from django.contrib.auth import models
class UserNode(DjangoObjectType):
class Meta:
model = models.User
interfaces = (relay.Node, )
class Query(AbstractType):
user = relay.Node.Field(UserNode)
def resolve_user(self, args, context, info):
if context.user.is_authenticated:
return context.user
Now when I run the same query, I get
`"Field \"user\" argument \"id\" of type \"ID!\" is required but not provided.",`
Is there any way to avoid having to supply relay ID?
Am I right in thinking overriding get_node
will not help much, since id
is a required argument?
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Authentication with GraphQL, React & Relay Tutorial
In this section, you'll learn how you can implement authentication functionality with Relay and Graphcool to provide a login to the user.
Read more >Getting Started with Relay - Auth0
Learn how to get started with a Relay app and how to protect the GraphQL endpoint with JWT authentication.
Read more >Authentication and Access Control with Relay - Stack Overflow
If anyone has problems with this topic: I made an example repo for Relay/GraphQL/express authentication based on dimadima's answer.
Read more >PetitPotam – NTLM Relay to AD CS - Penetration Testing Lab
It could be executed by supplying standard user credentials and using the IP of the system which NTLM Relay is configured and the...
Read more >Detecting NTLM Relay Attacks with CrowdStrike Identity ...
Because an authenticated user can still trigger an NTLM authentication from the domain controller, the NTLM relay attack vector remains relevant ...
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
Thanks @BossGrand, This tripped me up for a while trying to access and filter django object id’s using relay.
It would be great if the documentation was updated to show using Relay with
DjangoFilterConnectionField(Node)
for returning (and paginating) a set of results and thengraphene.Field(Node)
for accessing a single result with access to the underlying database model id.@JamesRamm
should be
In general when defining graphene types, you will use graphene.field