codegen-assets icon indicating copy to clipboard operation
codegen-assets copied to clipboard

Python codegen missing "Any" type, add default args

Open GavinRay97 opened this issue 4 years ago • 0 comments

Fixes issue where some GraphQL types are generated as Any but the Any import is not present in from typing import ....

Also fixes unrelated hidden bug where the codegen requires extend type Query/extend type Mutation as in our Action SDL to work properly. Now works for regular Query/Mutation. This was overriding and wiping out the base query + mutation types:

document.upsertObjectType(t.queryType({}))
document.upsertObjectType(t.mutationType({}))

Also adds placeholder arguments for the input type in Flask:

@app.route('/InsertUserAction', methods=['POST'])
def InsertUserActionHandler():
  args = InsertUserActionArgs.from_request(request.get_json())
  print(args)
  # business logic here
  return UserOutput(accessToken=, age=, email=, birthDate=).to_json()

Previously it would say return UserOutput().to_json() which was perhaps not immediately clear that it was a placeholder/needed args.

CC @praveenweb

GavinRay97 avatar Aug 17 '20 18:08 GavinRay97