-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[1.0] Creating Interfaces/Unions on sourcing/transforming/typegen? #885
Comments
So currently there's an API for extending the graphql types that Gatsby creates. You can see implementations in gatsby-typegen-remark and gatsby-typegen-sharp. A simplified implementation looks like: exports.extendNodeType = ({
type,
}) => {
if (type.name !== `TypeToModify`) {
return {}
}
return {
greeter: {
type: GraphQLString,
args: {
name: {
type: GraphQLString,
defaultValue: "Bob",
},
},
resolve(node, { name }) {
return `Hi ${name}!`
},
},
}
} What this doesn't let you do is create entirely new types. Is that what you'd need? We could easily add a new API hook at that'd let you mutate things however you want before the schema is created. |
I think I would need to create new types for union/interface types, yeah. I could probably change things to live without them if it's not something of interest to others, but that API hook would interest me. Should I take a stab at implementing it in a PR? |
Yes please! New API hooks are a one liner to add. |
Open PR for this @ #2990 |
Is |
Due to the high volume of issues, we're closing out older ones without recent activity. Please open a new issue if you need help! |
Is there a way to add Union types of Interfaces from plugins?
The text was updated successfully, but these errors were encountered: