-
Notifications
You must be signed in to change notification settings - Fork 179
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
make_executable_schema
's omits default enum values in args and inputs
#293
Comments
make_executable_schema
's omits default enum values in fields argsmake_executable_schema
's omits default enum values in args and inputs
Is there a workaround for this ? |
Any update on this? The issue was created quite a while ago and feels like a pretty common use case. I've only been playing with ariadne for a couple days and hit the bug immediately. |
PR's welcome :) In the meantime workaround for this issue is to define default value in field's resolver, eg:
|
It's unclear to me why this is not already done by |
|
The use of custom |
That may be the case, but please remember that this issue is mainly about |
This is not the case as long as enum Role {
ADMIN
USER
}
type Query {
hello(r: Role = USER): String
} And this query: {
default: hello
custom: hello(r: ADMIN)
} Resolver that returns {
"default": "'USER'",
"custom": "'ADMIN'"
} However as soon as {
"default": "'USER'",
"custom": "<Role.ADMIN: 'ADMIN'>"
} |
Turns out there's also a gotcha with Schema validation in GraphQL core which skips default values validation against enum definition: graphql-python/graphql-core#122 Without this its going to be super troublesome to offer useful error messages. I'll wait now to see what response to above issue will be given. If there's no, we may have to implement schema validator on our own for this case. |
I don't know if this is the right place to discuss this issue (it seems related to enums and default values): There seems to be a regression in ariadne 0.13.0. Or at least an unexpected change in behaviour when I upgraded from 0.12.0. If you run the following:
This works fine under the environment:
But when run under the environment:
It produces the error:
|
Perhaps this is obvious but, to add on to @dkbarn's previous comment, as it stands the default introspection query used by tools like GraphiQL and GraphQL Playground do not work. This results in the documentation tab and the auto-fill being broken in those tools. |
@dkbarn that looks like a bug all-right, but it should be separate issue on our tracker. Can you post it as separate bug? Thanks! |
Sure thing, separate issue created here: #547 |
Has there been any movement on the schema validation solution/workaround that would unblock this issue? My team is working on a project that is currently using workarounds for this and we'd like to remove them. |
GraphQL enums are represented in Python via the
GraphQLEnumType
. If those types are created from the SDL, they define no Python representation for GraphQL enum items. Developers can use Ariadne-providedEnumType
to specify how enum items should be represented in Python themselves, but we also include "fallback" step that fills enum values with theirstr
representations.However neither of those approaches takes care of enum items defined as default values for field arguments. Eg:
We will need to add additional step to
make_executable_schema
that gathers all enums from schema together with their Python representations, and then introspects schema's fields values for places where field or input has default value type of enum. If this is the case, we should set correctdefault_value
onGraphQLArgument
in the schema.The text was updated successfully, but these errors were encountered: