graphql server
This commit is contained in:
24
apps/cic-eth/cic_eth/graphql/app.py
Normal file
24
apps/cic-eth/cic_eth/graphql/app.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from cic_eth.graphql.schema import schema
|
||||
from flask import Flask
|
||||
from flask_graphql import GraphQLView
|
||||
|
||||
|
||||
def create_app():
|
||||
app = Flask(__name__)
|
||||
app.add_url_rule(
|
||||
'/graphql',
|
||||
view_func=GraphQLView.as_view(
|
||||
'graphql',
|
||||
schema=schema,
|
||||
graphiql=True
|
||||
)
|
||||
)
|
||||
@app.route("/")
|
||||
def test():
|
||||
return "Test ok!"
|
||||
|
||||
return app
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = create_app()
|
||||
app.run(host='0.0.0.0', port=5000)
|
||||
87
apps/cic-eth/cic_eth/graphql/helpers.py
Normal file
87
apps/cic-eth/cic_eth/graphql/helpers.py
Normal file
@@ -0,0 +1,87 @@
|
||||
|
||||
query_with_argument = """
|
||||
{
|
||||
defaultToken{
|
||||
symbol
|
||||
}
|
||||
}
|
||||
|
||||
"""
|
||||
# result = schema.execute(query_with_argument)
|
||||
# print(result)
|
||||
|
||||
|
||||
mutation_with_argument = """
|
||||
mutation {
|
||||
createAccount(password:"test"){
|
||||
address
|
||||
}
|
||||
}
|
||||
|
||||
"""
|
||||
m_result = schema.execute(mutation_with_argument)
|
||||
print(m_result)
|
||||
mutation_with_argument = """
|
||||
mutation {
|
||||
createAccount(password:"test"){
|
||||
address
|
||||
}
|
||||
}
|
||||
|
||||
"""
|
||||
m_result = schema.execute(mutation_with_argument)
|
||||
print(m_result)
|
||||
|
||||
balance_query = """
|
||||
query {
|
||||
balance(address:"0xcf41bd087b71c72d748fe2b8b4c88b2367c37df3", tokenSymbols:["GFT", "COFE"]){
|
||||
balanceNetwork
|
||||
balanceIncoming
|
||||
balanceOutgoing
|
||||
balanceAvailable
|
||||
}
|
||||
}
|
||||
|
||||
"""
|
||||
# balance_query_result = schema.execute(balance_query)
|
||||
# print(balance_query_result)
|
||||
|
||||
|
||||
transfer_mutation = """
|
||||
mutation {
|
||||
transfer(fromAddress :"0xcf41bd087b71c72d748fe2b8b4c88b2367c37df3",
|
||||
toAddress: "0x63474da1a315f9abe0999b6adb61ae8a9ea19a76"
|
||||
value: 20
|
||||
tokenSymbol: "COFE" ){
|
||||
test
|
||||
}
|
||||
}
|
||||
|
||||
"""
|
||||
transfer_mutation_result = schema.execute(transfer_mutation)
|
||||
print(transfer_mutation_result)
|
||||
|
||||
|
||||
balance_query = """
|
||||
query {
|
||||
balance(address:"0x63474da1a315f9abe0999b6adb61ae8a9ea19a76", tokenSymbols:["GFT"]){
|
||||
balanceNetwork
|
||||
balanceIncoming
|
||||
balanceOutgoing
|
||||
balanceAvailable
|
||||
}
|
||||
}
|
||||
|
||||
"""
|
||||
# balance_query_result = schema.execute(balance_query)
|
||||
# print(balance_query_result)
|
||||
|
||||
|
||||
transactions_query = """
|
||||
query {
|
||||
transactions(address:"0xcf41bd087b71c72d748fe2b8b4c88b2367c37df3")
|
||||
}
|
||||
|
||||
"""
|
||||
# transactions_query_result = schema.execute(transactions_query)
|
||||
# print(transactions_query_result)
|
||||
@@ -186,81 +186,3 @@ class MyMutations(ObjectType):
|
||||
|
||||
schema = Schema(query=Query, mutation=MyMutations)
|
||||
|
||||
|
||||
query_with_argument = """
|
||||
{
|
||||
defaultToken{
|
||||
symbol
|
||||
}
|
||||
}
|
||||
|
||||
"""
|
||||
# result = schema.execute(query_with_argument)
|
||||
# print(result)
|
||||
|
||||
|
||||
mutation_with_argument = """
|
||||
mutation {
|
||||
createAccount(password:"test"){
|
||||
address
|
||||
}
|
||||
}
|
||||
|
||||
"""
|
||||
# m_result = schema.execute(mutation_with_argument)
|
||||
# print(m_result)
|
||||
|
||||
|
||||
balance_query = """
|
||||
query {
|
||||
balance(address:"0x82e66cf2766bf20672a605bbf5a6faaa12d5b907", tokenSymbols:["GFT"]){
|
||||
balanceNetwork
|
||||
balanceIncoming
|
||||
balanceOutgoing
|
||||
balanceAvailable
|
||||
}
|
||||
}
|
||||
|
||||
"""
|
||||
# balance_query_result = schema.execute(balance_query)
|
||||
# print(balance_query_result)
|
||||
|
||||
|
||||
transfer_mutation = """
|
||||
mutation {
|
||||
transfer(fromAddress :"0xEb3907eCad74a0013c259D5874AE7f22DcBcC95C",
|
||||
toAddress: "0x82e66cf2766bf20672a605bbf5a6faaa12d5b907"
|
||||
value: 20
|
||||
tokenSymbol: "GFT" ){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
"""
|
||||
transfer_mutation_result = schema.execute(transfer_mutation)
|
||||
print(transfer_mutation_result)
|
||||
|
||||
|
||||
balance_query = """
|
||||
query {
|
||||
balance(address:"0xEb3907eCad74a0013c259D5874AE7f22DcBcC95C", tokenSymbols:["GFT"]){
|
||||
balanceNetwork
|
||||
balanceIncoming
|
||||
balanceOutgoing
|
||||
balanceAvailable
|
||||
}
|
||||
}
|
||||
|
||||
"""
|
||||
# balance_query_result = schema.execute(balance_query)
|
||||
# print(balance_query_result)
|
||||
|
||||
|
||||
transactions_query = """
|
||||
query {
|
||||
transactions(address:"0xEb3907eCad74a0013c259D5874AE7f22DcBcC95C")
|
||||
}
|
||||
|
||||
"""
|
||||
# transactions_query_result = schema.execute(transactions_query)
|
||||
# print(transactions_query_result)
|
||||
|
||||
@@ -3,4 +3,6 @@ chainlib-eth>=0.0.10a4,<0.1.0
|
||||
semver==2.13.0
|
||||
crypto-dev-signer>=0.4.15rc2,<0.5.0
|
||||
uwsgi==2.0.19.1
|
||||
graphene>=2.0
|
||||
graphene>=2.0
|
||||
flask>=2.0.2
|
||||
Flask-GraphQL>=2.0.1
|
||||
Reference in New Issue
Block a user