Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

Overriding remote custom scalars/enums not working when renaming types #34

Closed
yaacovCR opened this issue Jan 9, 2020 · 1 comment
Closed

Comments

@yaacovCR
Copy link
Owner

yaacovCR commented Jan 9, 2020

Currently, you can merge custom scalars/enums from a subschema and then provided new internal values such that the external values will be parsed into the internal ones prior to hitting your resolvers.

This is supported, although not necessarily a great idea, as the main purpose of internal values is when you know that you are going to be using an external api that expects these values to be of a different form -- see https://www.apollographql.com/docs/apollo-server/schema/scalars-enums/#internal-values -- and in this case the subschema is at least one external api that is expecting the values to be in the external form!

But, nevertheless, it is supportable, and supported. However, because type renaming is currently not handling directly by the stitching logic, but by user definable transforms, and there is no interaction between the transforms, the transform that performs the serialization of args prior to delegation (AddArgumentsAsVariables) and the transform that renames types (RenameTypes) cannot communicate, and so if the subschema has a type that is renamed, AddArgumentsAsVariables does not realize that it should use that types serializer.

This will only hit users if they are using schemaConfig objects within mergeSchemas, as if you fully transform the schema using wrapSchema or transformSchema prior to merging, and get hit by that extra round of delegation, all types in the subschema will be of the same name as the merged schema, avoiding this problem.

@yaacovCR
Copy link
Owner Author

yaacovCR commented Jan 9, 2020

Solutions include:

  1. Not supporting internal values for subschema enums/custom scalars.
  2. Allowing a context method by which transforms can communicate a la ApolloLink (or even by using an Apollo Link instead of transforms!)
  3. Ditching transforms altogether and integrating the commonly used transforms directly into options within mergeSchemas.

yaacovCR added a commit that referenced this issue Jan 21, 2020
now that all directly proxied args are serialized automatically, including variables, appropriate to standardize args passed to
delegateToSchema.

Previously, the typeName would be inferred from the proxy target, but serialization would be according to the gateway schema if the type names matched. This would introduce a lot of edge cases and was only necessary as a workaround to facilitate serialization of variables.

Now we can standardize as follows: args format is the internal representation of the proxy target schema. By default, local schemas internal representation will be imported, so that local schema custom enums/scalars do not require manual serialization. For remote schemas should, the internal and external representation is the same, so this is the same as the external representation. If the gateway introduces a new internal representation, args must be converted to the old internal representation manually.

addresses #34
reverts fd1bd8f#diff-06b180be3290dd53bea4c1c98c9dfdd2
yaacovCR added a commit that referenced this issue Jan 21, 2020
now that all directly proxied args are serialized automatically, including variables, appropriate to standardize args passed to
delegateToSchema.

Previously, the typeName would be inferred from the proxy target, but serialization would be according to the gateway schema if the type names matched. This would introduce a lot of edge cases and was only necessary as a workaround to facilitate serialization of variables.

Now we can standardize as follows: args format is the internal representation of the proxy target schema. By default, local schemas internal representation will be imported, so that local schema custom enums/scalars do not require manual serialization. For remote schemas should, the internal and external representation is the same, so this is the same as the external representation. If the gateway introduces a new internal representation, args must be converted to the old internal representation manually.

addresses #34
reverts fd1bd8f#diff-06b180be3290dd53bea4c1c98c9dfdd2
yaacovCR added a commit that referenced this issue Jan 21, 2020
now that all directly proxied args are serialized automatically, including variables, appropriate to standardize args passed to
delegateToSchema.

Previously, the typeName would be inferred from the proxy target, but serialization would be according to the gateway schema if the type names matched. This would introduce a lot of edge cases and was only necessary as a workaround to facilitate serialization of variables.

Now we can standardize as follows: args format is the internal representation of the proxy target schema. By default, local schemas internal representation will be imported, so that local schema custom enums/scalars do not require manual serialization. For remote schemas should, the internal and external representation is the same, so this is the same as the external representation. If the gateway introduces a new internal representation, args must be converted to the old internal representation manually.

addresses #34
reverts fd1bd8f#diff-06b180be3290dd53bea4c1c98c9dfdd2
yaacovCR added a commit that referenced this issue Feb 17, 2020
now that all directly proxied args are serialized automatically, including variables, appropriate to standardize args passed to
delegateToSchema.

Previously, the typeName would be inferred from the proxy target, but serialization would be according to the gateway schema if the type names matched. This would introduce a lot of edge cases and was only necessary as a workaround to facilitate serialization of variables.

Now we can standardize as follows: args format is the internal representation of the proxy target schema. By default, local schemas internal representation will be imported, so that local schema custom enums/scalars do not require manual serialization. For remote schemas should, the internal and external representation is the same, so this is the same as the external representation. If the gateway introduces a new internal representation, args must be converted to the old internal representation manually.

addresses #34
reverts fd1bd8f#diff-06b180be3290dd53bea4c1c98c9dfdd2
yaacovCR added a commit that referenced this issue Feb 27, 2020
now that all directly proxied args are serialized automatically, including variables, appropriate to standardize args passed to
delegateToSchema.

Previously, the typeName would be inferred from the proxy target, but serialization would be according to the gateway schema if the type names matched. This would introduce a lot of edge cases and was only necessary as a workaround to facilitate serialization of variables.

Now we can standardize as follows: args format is the internal representation of the proxy target schema. By default, local schemas internal representation will be imported, so that local schema custom enums/scalars do not require manual serialization. For remote schemas should, the internal and external representation is the same, so this is the same as the external representation. If the gateway introduces a new internal representation, args must be converted to the old internal representation manually.

addresses #34
reverts fd1bd8f#diff-06b180be3290dd53bea4c1c98c9dfdd2
yaacovCR added a commit that referenced this issue Mar 26, 2020
now that all directly proxied args are serialized automatically, including variables, appropriate to standardize args passed to
delegateToSchema.

Previously, the typeName would be inferred from the proxy target, but serialization would be according to the gateway schema if the type names matched. This would introduce a lot of edge cases and was only necessary as a workaround to facilitate serialization of variables.

Now we can standardize as follows: args format is the internal representation of the proxy target schema. By default, local schemas internal representation will be imported, so that local schema custom enums/scalars do not require manual serialization. For remote schemas should, the internal and external representation is the same, so this is the same as the external representation. If the gateway introduces a new internal representation, args must be converted to the old internal representation manually.

addresses #34
reverts fd1bd8f#diff-06b180be3290dd53bea4c1c98c9dfdd2
yaacovCR added a commit that referenced this issue Mar 26, 2020
now that all directly proxied args are serialized automatically, including variables, appropriate to standardize args passed to
delegateToSchema.

Previously, the typeName would be inferred from the proxy target, but serialization would be according to the gateway schema if the type names matched. This would introduce a lot of edge cases and was only necessary as a workaround to facilitate serialization of variables.

Now we can standardize as follows: args format is the internal representation of the proxy target schema. By default, local schemas internal representation will be imported, so that local schema custom enums/scalars do not require manual serialization. For remote schemas should, the internal and external representation is the same, so this is the same as the external representation. If the gateway introduces a new internal representation, args must be converted to the old internal representation manually.

addresses #34
reverts fd1bd8f#diff-06b180be3290dd53bea4c1c98c9dfdd2
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant