How to use the tartiflette.Scalar function in tartiflette

To help you get started, we’ve selected a few tartiflette examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tartiflette / tartiflette / tests / functional / regressions / issue228 / b_module.py View on Github external
async def bake(schema_name, config):
    Directive("Blah", schema_name=schema_name)(BlahDir(config))
    Scalar("NinjaGo", schema_name=schema_name)(NinjaGo)
    Resolver("Lol.ninja", schema_name=schema_name)(resolver_of_lol_ninja)
    return _SDL
github tartiflette / tartiflette / tests / functional / coercers / common.py View on Github external
def bake(schema_name, config):
    Scalar("DefaultRawInt", schema_name="coercion")(IntScalar())
    Scalar("DefaultRawString", schema_name="coercion")(StringScalar())
    Scalar("Boolean", schema_name="coercion")(BooleanScalar())
    Scalar("Float", schema_name="coercion")(FloatScalar())
    Scalar("Int", schema_name="coercion")(IntScalar())
    Scalar("String", schema_name="coercion")(StringScalar())
    Directive("debug", schema_name="coercion")(DebugDirective())
    Directive("lowercase", schema_name="coercion")(LowercaseDirective())
    Directive("increment", schema_name="coercion")(IncrementDirective())
    Directive("concatenate", schema_name="coercion")(ConcatenateDirective())
    Directive("mapToValue", schema_name="coercion")(MapToValueDirective())
    return ""
github tartiflette / tartiflette / tests / functional / coercers / test_coercer_variables_errors.py View on Github external
class InternalCoercionError:
        async def on_post_input_coercion(
            self, directive_args, next_directive, parent_node, value, ctx
        ):
            raise CoercionError("Oopsie")

    @Directive(
        "customCoercionError", schema_name="test_coercion_variables_errors"
    )
    class CustomCoercionError:
        async def on_post_input_coercion(
            self, directive_args, next_directive, parent_node, value, ctx
        ):
            raise ValueError("Oopsie")

    @Scalar("FirstErrorScalar", schema_name="test_coercion_variables_errors")
    @Scalar("SecondErrorScalar", schema_name="test_coercion_variables_errors")
    class ErrorScalars(ScalarString):
        pass

    return await create_engine(
        sdl=_SDL, schema_name="test_coercion_variables_errors"
    )
github tartiflette / tartiflette / tests / functional / coercers / common.py View on Github external
def bake(schema_name, config):
    Scalar("DefaultRawInt", schema_name="coercion")(IntScalar())
    Scalar("DefaultRawString", schema_name="coercion")(StringScalar())
    Scalar("Boolean", schema_name="coercion")(BooleanScalar())
    Scalar("Float", schema_name="coercion")(FloatScalar())
    Scalar("Int", schema_name="coercion")(IntScalar())
    Scalar("String", schema_name="coercion")(StringScalar())
    Directive("debug", schema_name="coercion")(DebugDirective())
    Directive("lowercase", schema_name="coercion")(LowercaseDirective())
    Directive("increment", schema_name="coercion")(IncrementDirective())
    Directive("concatenate", schema_name="coercion")(ConcatenateDirective())
    Directive("mapToValue", schema_name="coercion")(MapToValueDirective())
    return ""
github tartiflette / tartiflette / tests / functional / coercers / common.py View on Github external
def bake(schema_name, config):
    Scalar("DefaultRawInt", schema_name="coercion")(IntScalar())
    Scalar("DefaultRawString", schema_name="coercion")(StringScalar())
    Scalar("Boolean", schema_name="coercion")(BooleanScalar())
    Scalar("Float", schema_name="coercion")(FloatScalar())
    Scalar("Int", schema_name="coercion")(IntScalar())
    Scalar("String", schema_name="coercion")(StringScalar())
    Directive("debug", schema_name="coercion")(DebugDirective())
    Directive("lowercase", schema_name="coercion")(LowercaseDirective())
    Directive("increment", schema_name="coercion")(IncrementDirective())
    Directive("concatenate", schema_name="coercion")(ConcatenateDirective())
    Directive("mapToValue", schema_name="coercion")(MapToValueDirective())
    return ""
github remorses / mongoke / root / generated / scalars / __init__.py View on Github external
from tartiflette import Scalar
from bson import ObjectId

@Scalar("Json")
class Json:
    @staticmethod
    def coerce_input(val):
        return val

    @staticmethod
    def coerce_output(val):
        return val

@Scalar("ObjectId")
class ObjectIdScalar:
    @staticmethod
    def coerce_input(val):
        return ObjectId(val)

    @staticmethod
    def coerce_output(val):
        return str(val)

@Scalar("ID")
class IDClass:
    @staticmethod
    def coerce_input(val):
        return val

    @staticmethod
github remorses / mongoke / generated / generated / scalars.py View on Github external
JsonScalar = Scalar("Json")
@JsonScalar
class JsonClass:
    @staticmethod
    def coerce_input(val):
        return val

    @staticmethod
    def coerce_output(val):
        return val

    def parse_literal(self, ast: "Node") -> Union[str, "UNDEFINED_VALUE"]:
        return self.coerce_input(ast.value)

AnyScalarScalar = Scalar("AnyScalar")
@AnyScalarScalar
class AnyScalarClass:
    @staticmethod
    def coerce_input(val):
        if val == 'true':
            return True
        elif val == 'false':
            return False
        else:
            try:
                return float(val)
            except Exception:
                return str(val)

    @staticmethod
    def coerce_output(val):
github remorses / mongoke / root / generated / scalars / __init__.py View on Github external
    @staticmethod
    def coerce_output(val):
        return val

@Scalar("ObjectId")
class ObjectIdScalar:
    @staticmethod
    def coerce_input(val):
        return ObjectId(val)

    @staticmethod
    def coerce_output(val):
        return str(val)

@Scalar("ID")
class IDClass:
    @staticmethod
    def coerce_input(val):
        return val

    @staticmethod
    def coerce_output(val):
        return val
github tartiflette / tartiflette / tartiflette / scalar / builtins / datetime.py View on Github external
def bake(schema_name: str, config: Optional[Dict[str, Any]] = None) -> str:
    """
    Links the scalar to the appropriate schema and returns the SDL related
    to the scalar.
    :param schema_name: schema name to link with
    :param config: configuration of the scalar
    :type schema_name: str
    :type config: Optional[Dict[str, Any]]
    :return: the SDL related to the scalar
    :rtype: str
    """
    # pylint: disable=unused-argument
    Scalar("DateTime", schema_name=schema_name)(ScalarDateTime())
    return '''
    """The `DateTime` scalar type represents a date time object"""