-
-
Notifications
You must be signed in to change notification settings - Fork 677
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
Default values in default value of input types #615
Labels
Comments
Yes, this is a To reproduce: import {
GraphQLObjectType,
GraphQLString,
GraphQLInputObjectType,
GraphQLSchema,
printSchema,
graphql,
} from "graphql";
const Query = new GraphQLObjectType({
name: "Query",
fields: () => ({
sampleQuery: {
type: GraphQLString,
args: {
sampleArgs: {
type: SampleInput,
defaultValue: {},
},
},
resolve: (_, args) => {
console.log(args);
return "sampleQuery";
},
},
}),
});
const SampleInput = new GraphQLInputObjectType({
name: "SampleInput",
fields: {
sampleField: {
type: GraphQLString,
defaultValue: "default",
},
},
});
const schema = new GraphQLSchema({
types: [SampleInput],
query: Query,
});
console.log(printSchema(schema));
const query = /* graphql */ `
query {
sampleQuery
}
`;
graphql(schema, query).then(console.log);
Please open an issue in theirs repository or against GraphQL Spec 🔒 |
MichalLytek
added
Community 👨👧
Something initiated by a community
Invalid 👎
This doesn't seem right
labels
Apr 25, 2020
@backbone87 Did you ever figure out a solution for this? Or open an issue in their repo? |
@croossin i solved it by reusing the default value of the "parent" input object:
|
There is an open issue for it on Graphql-js, and a Graphql RFC. cc @croossin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Describe the Bug
When defining a default value for an input type, its default values are not applied. I am not sure if its a problem of type-graphql or graphql-js.
To Reproduce
{ myQuery }
with this query the log output is
{}
Expected Behavior
the log output should be
{take:30}
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: