graphql-platform icon indicating copy to clipboard operation
graphql-platform copied to clipboard

Add TypeContext parameter to ITypeInspector.GetMembers

Open atykhyy opened this issue 2 years ago • 1 comments

Following up on previous discussion, this PR adds a TypeContext parameter to ITypeInspector.GetMembers() so that it is easier for custom implementations to handle situations like ignoring computed read-only properties in input types.

atykhyy avatar Mar 04 '23 15:03 atykhyy

Would love to see this upstreamed, if I understand the discussion it spawned from correctly. Right now, code-reuse is made extremely difficult by the inability to reuse output objects as input objects if they contain read-only properties. It seems like an object which works for output should also work for input...

In other words, I would argue that if this code is valid:

public MyObject GetObject() => new MyObject();

Then this code should ALWAYS be valid:

public MyObject GetObject(MyObject obj) => obj;

However, right now that will fail with the class definition:

public class MyObject {
  public int Id { get; set; }

  public int HashCode => Id;
}

zaneclaes avatar Dec 06 '23 17:12 zaneclaes

Closing this PR as we now fixed the former mentioned issue with read-only props.

michaelstaib avatar Jul 08 '24 20:07 michaelstaib