提供普通标量的鞑靼花插件
tartiflette-plugin-scalars的Python项目详细描述
Tartiflete插件标量
提供通用标量的Tartiflette插件,用于数据验证和强类型API模式。在
要求
Python>;=3.6 酒石粉>;=1.0.0
安装
只需使用pip安装:
pip install tartiflette-plugin-scalars
然后开始编码,通过导入将其添加到tartiflette的create engine的modules列表中:
^{pr2}$配置
您可以通过在create_engine期间传递配置dict来配置插件。 此配置可用于禁用或重命名某些标量,如下所示:
engine = await create_engine(
sdl=sdl,
modules=[
{
"name": "tartiflette_plugin_scalars",
"config": {
"datetime": {"name": "MyDatetime"},
"postal_code": {"enabled": False},
},
}
],
schema_name="scalars",
)
一些插件还接受更具体的配置值,可以是
在名为options
的子字典中指定。选择是
在实例化时作为**kwargs
传递给init()
方法的标量。在
engine = await create_engine(
sdl=sdl,
modules=[
{
"name": "tartiflette_plugin_scalars",
"config": {
"datetime": {"name": "MyDatetime"},
"postal_code": {"enabled": False, "options": {"key": "value"}},
},
}
],
schema_name="scalars",
)
实现标量:
Name | Configuration key | Description |
---|---|---|
EmailAddress | email_address | Represents an email addresses |
DateTime | datetime | Represents a non naive datetime object |
NaiveDateTime | naive_datetime | Represents an optionally naive datetime object |
Duration | duration | Represents a timedelta object |
NegativeFloat | negative_float | Represents a negative floating point number |
NegativeInt | negative_int | Represents a negative integer |
NonNegativeFloat | non_negative_float | Represents a positive or 0 floating point number |
NonNegativeInt | non_negative_int | Represents a positive or 0 integer |
PositiveFloat | positive_float | Represents a positive floating point number |
PositiveInt | positive_int | Represents a positive integer |
NonPositiveFloat | non_positive_float | Represents a negative or 0 floating point number |
NonPositiveInt | non_positive_int | Represents a negative or 0 integer |
Long | long | Represents integers between 0 and 2^63 |
BigInt | big_int | Represents arbitrary length integers |
UnsignedInt | unsigned_int | Represents integers between 0 and 2^32 |
PhoneNumber | phone_number | Represents a phone number |
PostalCode | postal_code | Represents a postal code |
URL | url | Represents an Uniform Resource Locator |
GUID | guid | Represents a Globally Unique IDentifier |
UUID | uuid | Represents a Universally Unique IDentifier |
HexColorCode | hex_color_code | Hexadecimal representation of a color |
HSL | hsl | Hue, Saturation and Lightness of a color |
HSLA | hsla | Hue, Saturation, Lightness and Alpha of a color |
RGB | rgb | Red, Green, Blue of a color |
RGBA | rgba | Red, Green, Blue and Alpha of a color |
IPv4 | ipv4 | Represents an Internet Protocol version 4 address |
IPv6 | ipv6 | Represents an Internet Protocol version 6 address |
MAC | mac | Represents a Media Access Control address |
ISBN | isbn | Represents an International Standard Book Number |
Port | port | Represents a TCP / UDP port |
USCurrency | us_currency | Represents an amount of USD |
JSON | json | Represents a JSON value |
JSONObject | json_object | Represents a JSON object |
GeoJSON | geo_json | Represents a GeoJSON value |
- 项目
标签: