I'm currently adding extra properties to some graphql object field definitions, like the following:
const MutationType = new GraphQLObjectType({
name: 'Mutation',
fields: () => ({
AddSomething: {
// ... normal field properties
somethingElse: {},
}
}),
})
And then using them later on via the info argument inside some middlewares (using graphql-middleware):
const mutationField = info.schema.getMutationType().getFields()[info.fieldName];
console.log(mutationField.somethingElse);
For more details, see the following medium post: graphql mutation arguments validation using yup
The thing is, this is relying on internal behavior.
The following code spreads all properties given to the field:
|
const field = { |
|
...fieldConfig, |
|
isDeprecated: Boolean(fieldConfig.deprecationReason), |
|
name: fieldName, |
|
}; |
Is that something expected to not change? If yes, then no need for any other extra property or for this issue. 😄
But if this is something that can change in future versions, I would love the possibility of having an extra field for that extra metadata.
I'm available to work on adding this, if it's approved.
I'm currently adding extra properties to some graphql object field definitions, like the following:
And then using them later on via the
infoargument inside some middlewares (usinggraphql-middleware):For more details, see the following medium post: graphql mutation arguments validation using yup
The thing is, this is relying on internal behavior.
The following code spreads all properties given to the field:
graphql-js/src/type/definition.js
Lines 720 to 724 in 8171974
Is that something expected to not change? If yes, then no need for any other extra property or for this issue. 😄
But if this is something that can change in future versions, I would love the possibility of having an extra field for that extra metadata.
I'm available to work on adding this, if it's approved.