-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[Proposal] Add addField
method for object type
#1774
Comments
@pd4d10 All Can you please share your use case? |
Thanks for the quick reply. The current use case is, GraphQL types are generated at runtime from some other IDL, like Thrift or Protobuf. Sometimes it is not exactly we want. So I'm thinking a way to do some tweak based on it. It is also inspired by graphql-go: |
Since types are immutable by design, I guess the best practice is to manipulate |
@pd4d10 We are working on the new const config = objType.toConfig();
const modifiedType = new GraphQLObjectType({
...config,
fields: {
...config.fields,
add: { type: GraphQLInt },
},
}); But please note that other types can reference old type object so you need to also update them to point to modified type. Also, note that It's pretty low-level API and it's hard to use it directly that's why we working on adding more high-level Meanwhile, you can use external packages for schema manipulation, e.g. graphql-compose. I'm closing this issue since it will be fixed by |
Currently there seems no way to manipulate existing object types. It would be handy to have
addField
method as follows:The text was updated successfully, but these errors were encountered: