|
| 1 | +# generated by datamodel-codegen: |
| 2 | +# filename: union.graphql |
| 3 | +# timestamp: 2019-07-26T00:00:00+00:00 |
| 4 | + |
| 5 | +from __future__ import annotations |
| 6 | + |
| 7 | +from typing import Literal, Union |
| 8 | + |
| 9 | +from pydantic import BaseModel, Field |
| 10 | +from typing_extensions import TypeAliasType |
| 11 | + |
| 12 | +Boolean = TypeAliasType("Boolean", bool) |
| 13 | +""" |
| 14 | +The `Boolean` scalar type represents `true` or `false`. |
| 15 | +""" |
| 16 | + |
| 17 | + |
| 18 | +ID = TypeAliasType("ID", str) |
| 19 | +""" |
| 20 | +The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `"4"`) or integer (such as `4`) input value will be accepted as an ID. |
| 21 | +""" |
| 22 | + |
| 23 | + |
| 24 | +Int = TypeAliasType("Int", int) |
| 25 | +""" |
| 26 | +The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1. |
| 27 | +""" |
| 28 | + |
| 29 | + |
| 30 | +String = TypeAliasType("String", str) |
| 31 | +""" |
| 32 | +The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text. |
| 33 | +""" |
| 34 | + |
| 35 | + |
| 36 | +class IResource(BaseModel): |
| 37 | + id: ID |
| 38 | + typename__: Literal['IResource'] | None = Field('IResource', alias='__typename') |
| 39 | + |
| 40 | + |
| 41 | +class Car(IResource): |
| 42 | + id: ID |
| 43 | + passenger_capacity: Int = Field(..., alias='passengerCapacity') |
| 44 | + typename__: Literal['Car'] | None = Field('Car', alias='__typename') |
| 45 | + |
| 46 | + |
| 47 | +class Employee(IResource): |
| 48 | + first_name: String | None = Field(None, alias='firstName') |
| 49 | + id: ID |
| 50 | + last_name: String | None = Field(None, alias='lastName') |
| 51 | + typename__: Literal['Employee'] | None = Field('Employee', alias='__typename') |
| 52 | + |
| 53 | + |
| 54 | +Resource = TypeAliasType( |
| 55 | + "Resource", |
| 56 | + Union[ |
| 57 | + 'Car', |
| 58 | + 'Employee', |
| 59 | + ], |
| 60 | +) |
| 61 | + |
| 62 | + |
| 63 | +TechnicalResource = TypeAliasType("TechnicalResource", Car) |
0 commit comments