Skip to content

[WIP] InterfaceAttribute POC #4012

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

[WIP] InterfaceAttribute POC #4012

wants to merge 3 commits into from

Conversation

Shane32
Copy link
Member

@Shane32 Shane32 commented Aug 12, 2024

Depends on:

Demonstrates how [GraphQLInterface] (named here as [Interface]) could be implemented by a user or added directly to GraphQL.NET.

Discussion

Originally posted by @gao-artur in #4008 (comment):

Just a thought: why is there a need for the [Implements] attribute? Wouldn't it be simpler to mark an interface with something like [GraphQLInterface] and use it as a marker for implementing types?

Originally posted by @Shane32 in #4008 (comment):

There’s a few ways to attack this and I don’t know that I have the right answer. Currently we don’t enforce that for type-first that the .net types utilize inheritance. This makes things like adding arguments to an inherited method possible. (Although you could implement the original method privately or mark it with Ignore to mask it from GraphQL.) Also I’ve tried to keep attributes in the same relative location to the GraphQL schema. So while we could certainly and easily do what you suggested, someone reading the code would need to check all of the implemented interfaces of the CLR types to see if they are marked with GraphQLInterface or not. Further, since we don’t require marking with GraphQLInterface for other interface uses, this may be slightly confusing why it builds the interface but then doesn’t link any references to it. (Perhaps in the same way that it won’t now without ImplementsAtrribute…)

One question people might think is why doesn’t it just automatically generate GraphQL interfaces for all discovered interfaces on a CLR class. I don’t know about other people but this certainly wouldn’t work for me. I use inheritance within my code for database support and stuff that I don’t really want to expose to GraphQL. For example IHasDeleted marks any model that supports soft deletion - something that is oblivious to GraphQL callers.

I don’t use GraphQL interfaces much. But I can see how your suggestion may be preferred, so you don’t need to constantly write Implements throughout your code, which is a bit redundant. We could add it as another option - people don’t have to use either one.

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

Successfully merging this pull request may close these issues.

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy