From 888d7e82d711a464380b6fbb56c2342363d22ecc Mon Sep 17 00:00:00 2001 From: Vincent Texier <vit@free.fr> Date: Tue, 24 Jul 2018 09:56:30 +0200 Subject: [PATCH] issue #59 WIP: Add duniter GVA graphql schema Validate schema in request_swapi.py example --- duniterpy/api/gva/schema.qraphql | 29 +++++++++++++++++++++++++++++ examples/request_swapi.py | 10 ++++++++++ 2 files changed, 39 insertions(+) create mode 100644 duniterpy/api/gva/schema.qraphql diff --git a/duniterpy/api/gva/schema.qraphql b/duniterpy/api/gva/schema.qraphql new file mode 100644 index 00000000..558e8ad4 --- /dev/null +++ b/duniterpy/api/gva/schema.qraphql @@ -0,0 +1,29 @@ +schema { + query: Query +} + +type Query { + node: Node +} + +type Node { + summary: Summary + sandboxes: Sandboxes +} + +type Summary { + software: String! + version: String! + forkWindowSize: Int! +} + +type Sandbox { + size: Int! + free: Int! +} + +type Sandboxes { + identities: Sandbox! + memberships: Sandbox! + transactions: Sandbox! +} diff --git a/examples/request_swapi.py b/examples/request_swapi.py index 4322ac6e..b60aa142 100644 --- a/examples/request_swapi.py +++ b/examples/request_swapi.py @@ -1,4 +1,7 @@ import asyncio +import os + +import graphql from duniterpy.api.client import Client @@ -14,6 +17,13 @@ SWAPI_ENDPOINT = "BMAS swapi.graph.cool 443" async def main(): + + # validate duniter GVA graphql schema + with open(os.path.join(os.path.dirname(__file__), '../duniterpy/api/gva/schema.qraphql'), 'r') as fd: + document = graphql.parse(fd.read()) + schema = graphql.build_ast_schema(document) + print(schema) + client = Client(SWAPI_ENDPOINT) query = """query { -- GitLab