You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need to add @tag directive on custom scalar in our subgraph schema to control contracts, unfortunately it disappears during the subgraph schema generation (we call buildSubgraphSchema() with typeDefs and resolvers provided). It happens only if resolver for that custom scalar type is also added. Without the resolver directive is present in the final schema.
Whole astNode looks to be removed from the custom scalar type during schema build.
I trace problem down to this code in the addResolversToSchema method.
I'm not fully sure what is this code doing/copiing, but what helped me is to prevent astNode to be copied if it is empty:
if (isScalarType(type)) {
for (const fn in fieldConfigs) {
// CUSTOMIZATION: skip astNode copying if empty to keep directives etc on the scalar type definition
if (fn != "astNode" || (fieldConfigs as any)[fn])
(type as any)[fn] = (fieldConfigs as any)[fn];
}
}
The text was updated successfully, but these errors were encountered:
velias
changed the title
Directive can't be used on custom scalar definition
subgraph-js: directive can't be used on custom scalar definition
Dec 11, 2023
We need to add
@tag
directive on custom scalar in our subgraph schema to control contracts, unfortunately it disappears during the subgraph schema generation (we callbuildSubgraphSchema()
withtypeDefs
andresolvers
provided). It happens only if resolver for that custom scalar type is also added. Without the resolver directive is present in the final schema.Whole
astNode
looks to be removed from the custom scalar type during schema build.I trace problem down to this code in the
addResolversToSchema
method.federation/subgraph-js/src/schema-helper/buildSchemaFromSDL.ts
Line 135 in 160299f
I'm not fully sure what is this code doing/copiing, but what helped me is to prevent
astNode
to be copied if it is empty:The text was updated successfully, but these errors were encountered: