Define an object in graphql schema language and export it as GraphQLObjectType #7547
-
Hello, we have recently migrated away from express-graphql to Apollo Server. Currently our schema is built like so: // Image.js
export default new GraphQLObjectType({
name: 'Image',
fields: {
id: { type: GraphQLString, resolve: (block) => {...} },
alt: { type: GraphQLString, resolve: (block) => {...} }
}
})
// Media.js
import Image from './Image'
const Media = new GraphQLObjectType({
name: 'Media',
fields: {
image: { type: Image },
video: { type: Video }
}
}) I would like to gradually move to graphql schema language, preferably starting by declaring "leaf nodes" such as const typedefs = `#graphql
type Image {
id: String
alt: String
}
`
const resolvers = { ... }
export default schemaToGraphqlObject(typedefs, resolvers) Any help is appreciated, thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
trevor-scheer
May 4, 2023
Replies: 1 comment 1 reply
-
It looks like the |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
jmesimak
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It looks like the
mergeSchemas
function from@graphql-tools/schema
accomplishes what you're after?https://the-guild.dev/graphql/tools/docs/schema-merging