This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CustomInputField(graphene.InputObjectType): | |
| name = Stringy(validate='[a-zA-Z\s]*$') | |
| rate = Floaty(validate='^\d{1,2}(\.\d{1,10})?%$') | |
| fixed_amount = Floaty(validate='^\d+(\.\d*)?$') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function spreadsheetToPDF(key) { | |
| var oauthConfig = UrlFetchApp.addOAuthService("spreadsheets"); | |
| var scope = "https://spreadsheets.google.com/feeds" | |
| oauthConfig.setConsumerKey("anonymous"); | |
| oauthConfig.setConsumerSecret("anonymous"); | |
| oauthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope="+scope); | |
| oauthConfig.setAuthorizationUrl("https://accounts.google.com/OAuthAuthorizeToken"); | |
| oauthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| import graphene | |
| from graphql.language.ast import StringValue | |
| from graphene.types import Scalar | |
| pattern_list = [] | |
| def validate(value): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| import graphene | |
| from graphql.language.ast import BooleanValue, FloatValue, IntValue, StringValue | |
| from graphene.types import Scalar | |
| pattern_list = [] | |
| def validate(value): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from graphql.language.ast import StringValue | |
| from graphene.types import Scalar | |
| import graphene | |
| from myapp.types import UsageType | |
| pattern_list = [] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from graphql.language.ast import StringValue | |
| from graphene.types import Scalar | |
| import graphene | |
| from myapp.types import UsageType | |
| pattern_list = [] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from graphql.language.ast import StringValue | |
| from graphene.types import Scalar | |
| import graphene | |
| from myapp.types import UsageType | |
| class Stringy(Scalar): | |
| def __init__(self, *args, **kwargs): | |
| super().__init__(*args, **kwargs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from graphql.language.ast import StringValue | |
| from graphene.types import Scalar | |
| import graphene | |
| class Stringy(Scalar): | |
| def __init__(self, *args, **kwargs): | |
| super().__init__(*args, **kwargs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # custom scalar explained | |
| from graphene.types import Scalar | |
| from graphql.language import ast | |
| import graphene | |
| class Money(Scalar): | |
| @staticmethod | |
| def serialize(value): | |
| return int(value * Decimal(100)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from dataclasses import dataclass, field | |
| from typing import Any, Awaitable, Callable | |
| @dataclass(unsafe_hash=True) | |
| class ExtraValidators: | |
| func: Callable | |
| # all sub dicts are flattened to key: value level for validate function to work on | |
| flattened: dict = field(default_factory=dict, compare=False) |