title: How can I add / replace / remove a type from a GraphQLSchema?
body: <p>I am working on a GraphQL schema validation tool. I would like to update in memory my <code>GraphQLSchema</code> object.</p>
  
  <p>For instance to replace a type I tried to do:</p>
  
  <pre><code>const replaceType = (schema: GraphQLSchema, oldType: GraphQLNamedType, newType: GraphQLNamedType) =&gt; {
    const config = schema.toConfig();
    config.types = config.types.filter(t =&gt; t.name !== oldType.name);
    config.types.push(newType);
    return new GraphQLSchema(config);
  }
  </code></pre>
  
  <p>This however fails <a href="https://github.com/graphql/graphql-js/blob/master/src/type/schema.js#L222" rel="nofollow noreferrer">here</a> with </p>
  
  <pre><code>Schema must contain uniquely named types but contains multiple types named "MyType".
  
  at typeMapReducer (../../node_modules/graphql/type/schema.js:262:13)
  at Array.reduce (&lt;anonymous&gt;)
  at new GraphQLSchema (../../node_modules/graphql/type/schema.js:145:28)
  </code></pre>
  
  <p>It looks like there are existing references to the old type that I am not updating,</p>