You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have setup an lambda ApolloServer to act as a proxy endpoint to our Contentful GraphQL endpoint.
This proxy is aware of the calling user's role (Auth0 authorizer).
We'd like to modify VideoPost.url returned based on that role. Effectively to return a null for the VideoPost.url from non-pro (not logged in users) (Paywalled) We still want anonymous users to be able to query all videos... just not be able to view the video itself. Hence the idea is to just return VideoPost.url = null when anonymous.
Perhaps there is a better way to do this altogether, but right now we we're just trying to proxy the resolver for url field like this...
...and it's sort of working.
However, parent only includes what was asked for in the query.... so if the query didn't ask for parent.restrictToRoles then we are unable to modify things cause we don't know the restrictToRoles data on that VideoPost.
We considered using @requires but we're not entirely sure that will work when using a remote schema. Also, seems there is some kinda connection to "Apollo Federation" which we know nothing about. And things were erroring about Unknown directive "@requires" until we added the Federation schema specification and commenting out the Entity parts which were erroring out.
Our code now "runs" without error, but adding @requires to our VideoPost.url field has no effect.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
We have setup an lambda
ApolloServer
to act as a proxy endpoint to ourContentful GraphQL endpoint
.This proxy is aware of the calling user's
role
(Auth0 authorizer).We'd like to modify
VideoPost.url
returned based on that role. Effectively to return anull
for theVideoPost.url
from non-pro (not logged in users) (Paywalled) We still wantanonymous
users to be able to query all videos... just not be able to view the video itself. Hence the idea is to just returnVideoPost.url = null
when anonymous.Perhaps there is a better way to do this altogether, but right now we we're just trying to proxy the resolver for url field like this...
...and it's sort of working.
However,
parent
only includes what was asked for in the query.... so if the query didn't ask forparent.restrictToRoles
then we are unable to modify things cause we don't know therestrictToRoles
data on thatVideoPost
.Is there a better way to do this?
@requires
We considered using @requires but we're not entirely sure that will work when using a remote schema. Also, seems there is some kinda connection to "Apollo Federation" which we know nothing about. And things were erroring about
Unknown directive "@requires"
until we added the Federation schema specification and commenting out the Entity parts which were erroring out.Our code now "runs" without error, but adding
@requires
to ourVideoPost.url
field has no effect.Beta Was this translation helpful? Give feedback.
All reactions