graphql server

This commit is contained in:
William Luke 2021-11-01 10:48:05 +03:00
parent 0c84e970ad
commit c85692ab9e
6 changed files with 121 additions and 82 deletions

6
.envrc
View File

@ -1,2 +1,6 @@
export COMPOSE_DOCKER_CLI_BUILD=1
export DOCKER_BUILDKIT=1
export DOCKER_BUILDKIT=1
export FAUCET_AMOUNT=100000000000
export TOKEN_TYPE=giftable_erc20_token
export TOKEN_NAME=Coffee
export TOKEN_SYMBOL=COFE

View 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)

View 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)

View File

@ -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)

View File

@ -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

View File

@ -142,7 +142,7 @@ services:
TASKS_TRACE_QUEUE_STATUS: ${TASKS_TRACE_QUEUE_STATUS:-1}
restart: unless-stopped
ports:
- 8080:8000
- 5000:5000
depends_on:
- evm
- postgres
@ -158,7 +158,7 @@ services:
set -a
if [[ -f /tmp/cic/config/env_reset ]]; then source /tmp/cic/config/env_reset; fi
set +a
./start_tasker.sh --aux-all -q cic-eth -vv
./start_tasker.sh --aux-all -q cic-eth -vv & python /root/cic_eth/graphql/app.py
cic-eth-tracker:
image: ${DEV_DOCKER_REGISTRY:-registry.gitlab.com/grassrootseconomics/cic-internal-integration}/cic-eth:${TAG:-latest}