graphql-dotnet / conventions

GraphQL Conventions Library for .NET
MIT License
233 stars 63 forks source link

Change IUserContext #248

Closed Shane32 closed 1 year ago

Shane32 commented 1 year ago

This PR changes IUserContext to inherit from IDictionary<string, object> so that it can be stored directly within IResolveFieldContext.UserContext.

Advantages:

See:

However:

Possible helper "solution" we could provide: provide a UserContext base class which exposes no members except through the implemented IDictionary<string, object> interface. Users can inherit from this class, and their strongly-typed class will not show any dictionary members on it.

tlil commented 1 year ago

Possible helper "solution" we could provide: provide a UserContext base class which exposes no members except through the implemented IDictionary<string, object> interface. Users can inherit from this class, and their strongly-typed class will not show any dictionary members on it.

Yes, we can have a UserContextBase class like you suggest, implementing IDictionary<string, object> as a helper class

Shane32 commented 1 year ago

Yes, we can have a UserContextBase class like you suggest, implementing IDictionary<string, object> as a helper class

See attached. Folder / namespace?

tlil commented 1 year ago

See attached. Folder / namespace?

As-is works for me. Thanks