question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support skipping readonly fields

See original GitHub issue

Product

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:open
  • Created 4 months ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
xionglingfengcommented, May 22, 2023

Yes. I would expect HotChocolate to skip this field when generating schema for MyInputClassInput. However, the field can be kept when generating schema for MyInputClass (not Input).

This read-only field is actually expected when using the class as a return type. Thus I cannot apply [GraphQLIgnore].

0reactions
michaelstaibcommented, Jun 6, 2023

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.

services
    .AddGraphQLServer()
    .AddInputType<MyInputClass>(t => t.Ignore(d => d.Names));

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found