Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not compatible with graphql-dotnet 3.0 #71

Closed
withinboredom opened this issue Jan 28, 2020 · 4 comments
Closed

Not compatible with graphql-dotnet 3.0 #71

withinboredom opened this issue Jan 28, 2020 · 4 comments

Comments

@withinboredom
Copy link

withinboredom commented Jan 28, 2020

In the latest of graphql-dotnet UserContext is expected to be a Dictionary<string, object> and not an object.

This could probably be handled by adding a simple bit:

// var userContext = context.UserContext as IProvideClaimsPrincipal;
IProvideClaimsPrinciple userContext;
if(context.UserContext is Dictionary<string, object>) {
  userContext = (context.UserContext as Dictionary<string, object>)?["user"] as IProvideClaimsPrinciple;
} else {
  userContext = context.UserContext as IProvideClaimsPrinciple;
}
@sungam3r
Copy link
Member

Can you explain the problem in more detail?

@withinboredom
Copy link
Author

withinboredom commented Jan 29, 2020

Sure, the ValidationContext implements IProvideUserContext which an IDictionary and not an Object (like it was in earlier versions). This means, in the very least, that either:

  1. GraphQLUserContext needs to also implement IDictionary<string, object>
  2. or, GraphQLUserContext needs to check a "well-known" key for the principle.

As it stands right now, it doesn't work at all unless (1) is implemented because ExecutionOptions only accepts an IDictionary<string, object>

@sungam3r
Copy link
Member

sungam3r commented Jan 29, 2020

the ValidationContext implements IProvideUserContext which an IDictionary and not an Object 

This is the expected behavior. https://github.com/graphql-dotnet/authorization/blob/master/src/Harness/GraphQL.cs#L8 , examples have been modified accordingly.

Do you have a runtime error?

@withinboredom
Copy link
Author

Oh, nice I missed that! Closing this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants