Support skipping readonly fields
See original GitHub issueProduct
Hot Chocolate
Is your feature request related to a problem?
We have a class generated from XSD. This class include generated fields like XXSpecified
, which are mandatory to XmlSerializer. For example:
/// <summary>
/// <para xml:lang="en">Gets a value indicating whether the Error collection is empty.</para>
/// </summary>
[XmlIgnoreAttribute()]
public bool ErrorSpecified
{
get
{
return (this.Error.Count != 0);
}
}
Once we use this class as an Input type, HotChocolate will complain that the XXSpecified
fields are read-only. Can we have options to allow skipping read-only fields?
The solution you’d like
Read-only fields are automatically skipped when using as Input.
Issue Analytics
- State:
- Created 4 months ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How to Skip ReadOnly and Disabled inputs while using . ...
focus() the first form object if it is readonly or disabled and to skip to the next form input for focus? Currently it...
Read more >Skip read-only fields when TAB is pressed.
Please can you tell me if and how it is possible to 'skip' over read-only fields when navigating through a form using TAB....
Read more >Silent skipping of read-only fields that throw exceptions ...
I have a serializer with some read-only fields which are populated by a method on the model. This worked great.
Read more >Tab Stops should skip read only fields
Hi Daniel - According to the response I got from support, this is now working as designed. Apparently tab order was always supposed...
Read more >Serialize readonly field
Unity can't serialize readonly fields. Readonly fields can only be set in either the object initializer or the constructor of the class.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes. I would expect HotChocolate to skip this field when generating schema for
MyInputClassInput
. However, the field can be kept when generating schema forMyInputClass
(not Input).This read-only field is actually expected when using the class as a return type. Thus I cannot apply
[GraphQLIgnore]
.In this case the GraphQL schema would be invalid as the input would end up with no fields which is not allowed by the GraphQL spec. What you can do is specify type configurations that describe the input and output behavior.
If you have multiple of these you can override the DefaultTypeInspector and ignore these on input. But as I said, it will fail if the input ha no other fields.