Skip to content

Instantly share code, notes, and snippets.

@zer0tonin zer0tonin/app.py
Created Nov 4, 2019

Embed
What would you like to do?
tartiflette-plugin-scalars example
import asyncio
from ipaddress import ip_address
from tartiflette import Resolver, create_engine
from aiohttp import web
from tartiflette_aiohttp import register_graphql_handlers
@Resolver("Query.ipAddress")
async def resolve_ip_address(parent, args, ctx, info):
return ip_address("127.0.0.1")
@Resolver("Query.port")
async def resolve_port(parent, args, ctx, info):
return 8080
@Resolver("Mutation.checkGUID")
async def resolve_guid(parent, args, ctx, info):
return args["input"]
async def engine():
with open("schema.sdl") as schema:
return await create_engine(
schema.read(),
modules=[
{
"name": "tartiflette_plugin_scalars",
"config": {},
}
],
)
web.run_app(
register_graphql_handlers(
web.Application(),
engine=engine(),
)
)
type Query {
ipAddress: IPv4
port: Port
}
type Mutation {
checkGUID(input: GUID!): GUID!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.