Skip to content

Empty String as As input variable #18

Closed
@eMerzh

Description

@eMerzh

Hello,
not sure if it's an issue or a question, but here it is,
i try to make a field with a non nullable String as an input field. And graphql-core-next is converting it to "None" which is not what i expected.
It seems to me, reading the spec, that it's allowed to pass "" as string argument and should be considered not null ... did i miss something ?

here is a reproducible code to show off the issue :

import asyncio
from graphql import graphql, parse, build_ast_schema


async def resolve_hello(obj, info, query):
    print(query)
    return f'world ==>{query}<=='

schema = build_ast_schema(parse("""
type Query {
    hello(query: String!): String
}
"""))

schema.get_type("Query").fields["hello"].resolve = resolve_hello

async def main():
    query = '{ hello(query: "") }'
    print('Fetching the result...')
    result = await graphql(schema, query)
    print(result)


loop = asyncio.get_event_loop()
try:
    loop.run_until_complete(main())
finally:
    loop.close()

thanks for the help 👍

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions