Cooperative Blue is mock backend for cooperative buhality party.
Ivan Asmer b994cb09f3 fixes | 5 years ago | |
---|---|---|
README.md | 5 years ago | |
index.js | 5 years ago | |
models.js | 5 years ago | |
package.json | 5 years ago |
git clone
cd cooperative-blue
npm i
node index.js
mongodb on localhost
mutation createUser($login:String!, $password:String!){
createUser(login:$login, password:$password){
_id, login
}
}
query login($login:String!, $password:String!){
login(login:$login, password:$password)
}
mutation pwd($password:String!){
changePassword(password: $password){
_id, login
}
}
mutation createEvent($name:String!, $total:Float!){
createEvent(name:$name,total:$total){
_id, name
}
}
mutation changeEvent($eventId:String!, $name:String!, $total:Float!){
changeEvent(eventId:$eventId, name:$name, total:$total){
_id, name, owner
}
}
query events{
events{
_id, name, owner, usersSum, moneyDiff, total
}
}
mutation createEventMoney($eventId:String!, $amount:Float!){
createEventMoney(eventId:$eventId, amount:$amount){
_id, user{
_id,login
}, event{
_id, name}
, amount
}
}
query em{
eventMoneys{
_id,
user{
_id,
login
}
event{
_id,
}
amount
}
}
query eme($eventId: String!){
eventMoneysByEvent(eventId:$eventId){
_id,
owner,
event{
_id,
}
amount
}
}
createUser
and login
works without jwt token,
All others resolvers runs only with token provided.
To teach graphiql works with token open console and substitute
fetch
with tuned one:
let authToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOnsiaWQiOiI1ZDMzM2I0MjM2MjZlMDc2ZTRjZjcyNDEiLCJsb2dpbiI6ImZvbyJ9LCJpYXQiOjE1NjM2Mzg2MTJ9.G2PxsUH8-ODv07hz_sP_JJfILxymlOw3lPDGgwBzvuk";
const originalFetch = fetch;
fetch = (url, params={headers:{}}) => {
params.headers.Authorization = "Bearer " + authToken
return originalFetch(url, params)
}
this new fetch
will override default, so graphiql will pass authorization header
with every query;