Closed CharlesW95 closed 3 years ago
Just reading the source code, I don't think this is currently possible without manually overriding, i.e.
class MyClassType(PydanticObjectType):
class Meta:
model = MyClassModel
myList = graphene.List(graphene.NonNull(String), required=True)
I haven't tested this, but I think the fix would be here to replace:
return List(graphene_type)
with
if not field.sub_fields[0].allow_none:
graphene_type = graphene.NonNull(graphene_type)
return List(graphene_type)
i.e. inspecting the nullability of the first subfield
@daviddaskell Thank you! Only need this in one case so going to use the manual override for now.
Right now, when my pydantic model looks like the following:
and my graphene model looks like this:
the GraphQL schema output for this field looks like this:
This means that introspection in TypeScript interprets each element in the List as a
Maybe<String>
instead of aString
. What can I do here to ensure that the type ismyList: [String!]!
?Thanks!