Skip to content
Snippets Groups Projects
Commit ee73475d authored by Vincent Texier's avatar Vincent Texier
Browse files

issue #59 WIP: graphql lib removed, get schema query added

parent a82dc84e
No related branches found
No related tags found
No related merge requests found
...@@ -179,7 +179,7 @@ class API: ...@@ -179,7 +179,7 @@ class API:
return response return response
async def requests(self, method: str = 'GET', path: str = '', data: Optional[dict] = None, async def requests(self, method: str = 'GET', path: str = '', data: Optional[dict] = None,
_json: Optional[dict] = None) -> aiohttp.ClientResponse: _json: Optional[dict] = None) -> ClientResponse:
""" """
Generic requests wrapper on aiohttp Generic requests wrapper on aiohttp
......
query IntrospectionQuery {
__schema {
queryType {
name
}
mutationType {
name
}
subscriptionType {
name
}
types {
...FullType
}
directives {
name
description
locations
args {
...InputValue
}
}
}
}
fragment FullType on __Type {
kind
name
description
fields(includeDeprecated: true) {
name
description
args {
...InputValue
}
type {
...TypeRef
}
isDeprecated
deprecationReason
}
inputFields {
...InputValue
}
interfaces {
...TypeRef
}
enumValues(includeDeprecated: true) {
name
description
isDeprecated
deprecationReason
}
possibleTypes {
...TypeRef
}
}
fragment InputValue on __InputValue {
name
description
type {
...TypeRef
}
defaultValue
}
fragment TypeRef on __Type {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
}
}
}
}
}
}
}
}
\ No newline at end of file
schema {
query: Query
mutation: Mutation
}
#################################
# NODE types
#################################
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!
}
#################################
# WOT types
#################################
type Identity {
version: Int!
type: String!
currency: String!
issuer: String!
uniqueID: String!
timestamp: String!
signature: String!
}
#################################
# NODE queries
#################################
type Query {
node: Node
}
#################################
# WOT mutations
#################################
type Mutation {
addIdentity (
signedRaw: String!
): Identity
}
import asyncio import asyncio
import os import os
import graphql
from duniterpy.api.client import Client from duniterpy.api.client import Client
# CONFIG ####################################### # CONFIG #######################################
...@@ -12,19 +10,23 @@ from duniterpy.api.client import Client ...@@ -12,19 +10,23 @@ from duniterpy.api.client import Client
# Here we use the secure BASIC_MERKLED_API (BMAS) # Here we use the secure BASIC_MERKLED_API (BMAS)
SWAPI_ENDPOINT = "BMAS swapi.graph.cool 443" SWAPI_ENDPOINT = "BMAS swapi.graph.cool 443"
GRAPHQL_GET_SCHEMA_QUERY_FILEPATH = "../duniterpy/api/gva/get_schema_query.graphql"
GRAPHQL_SCHEMA_FILEPATH = "/tmp/duniterpy_example_swapi_schema.graphql"
################################################ ################################################
async def main(): async def main():
client = Client(SWAPI_ENDPOINT)
# validate duniter GVA graphql schema # get SWAPI graphql schema
with open(os.path.join(os.path.dirname(__file__), '../duniterpy/api/gva/schema.qraphql'), 'r') as fd: with open(os.path.join(os.path.dirname(__file__), GRAPHQL_GET_SCHEMA_QUERY_FILEPATH), 'r') as fd:
document = graphql.parse(fd.read()) query = fd.read()
schema = graphql.build_ast_schema(document)
print(schema)
client = Client(SWAPI_ENDPOINT) response = await client.query(query)
print(response)
query = """query { query = """query {
allFilms { allFilms {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment