Multiple schema directives syntax in @graphql-tools/schema v8 #3419
-
Hey 👋 After v7 makeExecutableSchema({
typeDefs,
schemaTransforms: [
userDirectiveTransformer,
validUserDirectiveTransformer
]
}) v8 userDirective()(validUserDirective()(makeExecutableSchema({
typeDefs
}))) What's the syntax for multiple directives? Is example above suggested one or I'm missing something? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
const directiveTransformers = [userDirectiveTransformer, validUserDirectiveTransformer];
const schema = directiveTransformers.reduce((schema, transformer) => transformer(schema), makeExecutableSchema({ typeDefs })) |
Beta Was this translation helpful? Give feedback.
-
Just linking to this here: #3279 |
Beta Was this translation helpful? Give feedback.
-
Thanks! Yeah, I've seen #3279, using reducer is okay though I much prefer syntax of v7 as friendlier one. Since multiple directives sound like a common case, would be nice to see such example with reducer in the docs so other devs immediately see solution 😉 |
Beta Was this translation helpful? Give feedback.
-
Another solution that can be used is to use mapSchema
|
Beta Was this translation helpful? Give feedback.
schemaTransforms
has been removed so you can chain the functions that manipulate the schema by yourself.For example;