Skip to content

Instantly share code, notes, and snippets.

View rob-blackbourn's full-sized avatar
💭
Trying to do a proper "Hello, World!" with wasm

Rob Blackbourn rob-blackbourn

💭
Trying to do a proper "Hello, World!" with wasm
View GitHub Profile
@rob-blackbourn
rob-blackbourn / client.py
Created May 23, 2023 18:18
Using asyncio start_tls with Python 3.11
"""
Example Client
The client connects without TLS, but using the fully qualified domain name. To
authenticate the server, the FQDN is required. This can be specified either at
connection time, or with the start_tls call.
First the client sends a "PING" over the unencrypted stream to the server. The
server should respond with "PONG".
@rob-blackbourn
rob-blackbourn / graphene3-demo-server.py
Created October 8, 2020 08:12
Graphene 3 example server
import asyncio
import signal
from typing import Any, Mapping
from bareasgi import Application
import pkg_resources
import hypercorn.asyncio
import hypercorn.config
from demo.app import make_application
@rob-blackbourn
rob-blackbourn / graphene3-demo-schema.py
Created October 8, 2020 08:09
Graphene 3 example schema
import graphene
from .queries import Query
from .mutations import Mutations
from .subscriptions import Subscription
SCHEMA = graphene.Schema(query=Query, mutation=Mutations, subscription=Subscription)
@rob-blackbourn
rob-blackbourn / graphene3-demo-app.py
Created October 8, 2020 08:06
Graphene 3 example ASGI application
import os
from typing import Any, Mapping
from bareasgi import Application
from bareasgi_cors import CORSMiddleware
from bareasgi_graphql_next.graphene import add_graphene
from baretypes import (
Scope,
Info,
Message
@rob-blackbourn
rob-blackbourn / graphene3-demo-subscription.py
Last active October 8, 2020 10:19
Graphene 3 example subscription
import typing
import graphene
from jetblack_tweeter import Tweeter
from .types import TweetType
class Subscription(graphene.ObjectType):
filter = graphene.Field(
TweetType,
@rob-blackbourn
rob-blackbourn / graphene3-demo-mutation.py
Created October 8, 2020 07:56
Graphene 3 example mutation
import typing
import graphene
from jetblack_tweeter import Tweeter
from ..types import TweetType
class UpdateStatus(graphene.Mutation):
class Arguments:
status = graphene.String()
@rob-blackbourn
rob-blackbourn / graphene3-demo-query.py
Created October 8, 2020 07:47
Graphene 3 example query
import typing
import graphene
from jetblack_tweeter import Tweeter
from .types import SearchResultType
class Query(graphene.ObjectType):
search_tweets = graphene.Field(
SearchResultType,
@rob-blackbourn
rob-blackbourn / graphene3-demo-types.py
Created October 8, 2020 07:24
Graphhene 3 types for twitter demo
import graphene
class UserType(graphene.ObjectType):
id = graphene.types.scalars.BigInt(required=True)
id_str = graphene.String(required=True)
name = graphene.String(required=True)
screen_name = graphene.String(required=True)
location = graphene.String(required=False)
url = graphene.String(required=False)
description = graphene.String(required=False)
@rob-blackbourn
rob-blackbourn / jetblack-tweeter-graphene-ex1.py
Created October 8, 2020 07:05
The twitter calls using jetblack-tweeter
import asyncio
import os
from jetblack_tweeter import Tweeter
from jetblack_tweeter.clients.bareclient import BareTweeterSession
async def main():
# Create the twitter client.
tweeter = Tweeter(
BareTweeterSession(),
@rob-blackbourn
rob-blackbourn / graphql_json_type.py
Created September 20, 2019 07:19
A Python GraphQL JSON type for graphqlql-core-next v1.1.1
"""GraphQL JSON type"""
import json
from typing import List, Mapping, Union, Any
from graphql.type import GraphQLScalarType
from graphql.language.ast import StringValueNode
from graphql.error import INVALID
JSONType = Union[List[Mapping[str, Any]], Mapping[str, Any]]