Package: graphql-pydantic-transformer
GraphQL to Pydantic Transformer & Pydantic to Query BuilderOverviewTheGraphQL to Pydantic Transformeris a Python package designed to simplify the process of transforming GraphQL
schemas in JSON format into Pydantic models. This tool is particularly useful for developers working with GraphQL
APIs who want to generate Pydantic models from GraphQL types for efficient data validation
and serialization/deserialization.FeaturesConverts GraphQL schemas in JSON format into Pydantic models.Build query or mutation from pydantic dataclassInstallationYou can install theGraphQL to Pydantic Transformerpackage via pip:pipinstallgraphql-pydantic-transformerUsageCli tool to transform GraphQL JSON to Pydanticgraphql-pydantic-converter[-h][-iINPUT_FILE][-oOUTPUT_FILE][--urlURL][--headersHEADERS[HEADERS...]]options:-h,--helpshowthishelpmessageandexit-iINPUT_FILE,--input-fileINPUT_FILE-oOUTPUT_FILE,--output-fileOUTPUT_FILE--urlURL--headersHEADERS[HEADERS...]# --headers "HeaderName: HeaderValue" "HeaderName: HeaderValue"Output from cli toolimporttypingfrompydanticimportFieldfromgraphql_pydantic_converter.graphql_typesimportInputfromgraphql_pydantic_converter.graphql_typesimportMutationfromgraphql_pydantic_converter.graphql_typesimportPayloadBoolean:typing.TypeAlias=boolDateTime:typing.TypeAlias=typing.AnyFloat:typing.TypeAlias=floatID:typing.TypeAlias=strInt:typing.TypeAlias=intJSON:typing.TypeAlias=typing.AnyString:typing.TypeAlias=strclassCreateScheduleInput(Input):name:Stringworkflow_name:String=Field(alias='workflowName')workflow_version:String=Field(alias='workflowVersion')cron_string:String=Field(alias='cronString')enabled:typing.Optional[Boolean]parallel_runs:typing.Optional[Boolean]=Field(alias='parallelRuns')workflow_context:typing.Optional[String]=Field(alias='workflowContext')from_date:typing.Optional[DateTime]=Field(alias='fromDate')to_date:typing.Optional[DateTime]=Field(alias='toDate')classSchedule(Payload):name:typing.Optional[Boolean]=Field(response='String',default=True)enabled:typing.Optional[Boolean]=Field(response='Boolean',default=True)parallel_runs:typing.Optional[Boolean]=Field(response='Boolean',alias='parallelRuns',default=True)workflow_name:typing.Optional[Boolean]=Field(response='String',alias='workflowName',default=True)workflow_version:typing.Optional[Boolean]=Field(response='String',alias='workflowVersion',default=True)cron_string:typing.Optional[Boolean]=Field(response='String',alias='cronString',default=True)workflow_context:typing.Optional[Boolean]=Field(response='String',alias='workflowContext',default=True)from_date:typing.Optional[Boolean]=Field(response='DateTime',alias='fromDate',default=True)to_date:typing.Optional[Boolean]=Field(response='DateTime',alias='toDate',default=True)status:typing.Optional[Boolean]=Field(response='Status',default=True)classCreateScheduleMutation(Mutation):_name:str=Field('createSchedule',const=True)input:CreateScheduleInputpayload:ScheduleCreateScheduleInput.update_forward_refs()CreateScheduleMutation.update_forward_refs()Schedule.update_forward_refs()Query & Mutation builderfromschedule_apiimportSchedule,CreateScheduleMutation,CreateScheduleInputSCHEDULE:Schedule=Schedule(name=True,enabled=True,workflowName=True,workflowVersion=True,cronString=True,fromDate=False,toDate=False,status=False)mutation=CreateScheduleMutation(payload=SCHEDULE,input=CreateScheduleInput(name='name',workflowName='workflowName',workflowVersion='workflowVersion',cronString='* * * * *',enabled=True,parallelRuns=False,))mutation.render()Created querymutation{createSchedule(input:{name:"name"workflowName:"workflowName"workflowVersion:"workflowVersion"cronString:"* * * * *"enabled:trueparallelRuns:false}){nameenabledparallelRunsworkflowNameworkflowVersioncronStringworkflowContext}}