Lets say I have the following GraphQL schema written in graphene,
class Query(graphene.ObjectType):
dummy_query = graphene.Field(String, name=graphene.String(required=True))
def resolve_dummy_query(self, info, name):
print(type(name))
return None
I am using Flask to host this API,
view_func = GraphQLView.as_view('graphql',
schema=graphene.Schema(query=Query),
graphiql=True)
app = Flask(__name__)
app.add_url_rule('/graphql', view_func=view_func)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=os.environ.get('PORT', 5000))
The following is the query I'm providing using GraphiQL
{
dummyQuery(name: "My name")
}
When the resolve function is getting executed, the type of name is being shown as unicode.
Is there a way to specify a type converter in the schema definition so that this gets converted to str when it is in the resolve function?
Note:
- I'm using python 2.7
- I can't manually convert it to
streverytime because the application is large and there are many input types which I would like to convert to other types.