title: Cleaning Unwanted Fields From GraphQL Responses
body: <p>I have an object that my GraphQL client requests.</p>
  
  <p>It's a reasonably simple object:</p>
  
  <pre><code>type Element {
      content: [ElementContent]
      elementId: String
      name: String
      notes: String
      type: String
      createdAt: String
      updatedAt: String
    }
  </code></pre>
  
  <p>With the special type <code>ElementContent</code>, which is tiny and looks like this:</p>
  
  <pre><code>  type ElementContent {
      content: String
      locale: String
    }
  </code></pre>
  
  <p>Now, when I query this on the clientside, both the top level object and the lower level object has additional properties (which interfere with updating the object if I attempt to clone the body exactly-as-is);</p>
  
  <p>Notably, GraphQL seems to supply a <code>__typename</code> property in the parent object, and in the child objects, they have typename and a <code>Symbol(id)</code> property as well.</p>
  
  <p><a href="https://i.stack.imgur.com/ZFxO6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ZFxO6.png" alt="enter image description here"></a></p>
  
  <p>I'd love to copy this object to state, update in state, then clone the state and ship it to my <code>update</code> mutation. However, I get roadblocked because of unknown properties that GraphQL itself supplies.</p>
  
  <p>I've tried doing:</p>
  
  <p><code>delete element.__typename</code> to good effect, but then I also need to loop through the children (a dynamic array of objects), and likely have to remove those properties as well.</p>
  
  <p>I'm not sure if I'm missing something during this equation, or I should just struggle through the code and loop + delete (I received errors attempting to do a forEach loop initially). Is there a better strategy for what I'm attempting to do? Or am I on the right path and just need some good loop code to clean unwanted properties?</p>