I have tried GQL quickstart:
and
I have followed the tutorial at
closely adapting it to my own db
Here is the schema:
type User
{
active : Boolean!
user_name : String! @unique
password : String! @unique
ethaddress : String! @unique
description : String
email : String @unique
mobile : String @unique
member_since: Int!
}
type Player
{ address : String! @unique
rank : Int!
challengeraddress : String
}
type Ranking
{
active : Boolean!
rankingname : String! @unique
rankingdesc : String
rankingowneraddr : String! @unique
}
type UserJoinedRanking
{
active : Boolean!
rankingid : Int!
rankingname : String!
rankingowneraddr : String!
}
type Todo {
title: String!
completed: Boolean
}
type Mutation {
createAndOrLoginUser(active: Boolean!, user_name: String!, password: String!, ethaddress: String!, description: String, email: String, mobile: String): String! @resolver(name: "create_andor_login_user")
createNewPlayer(active: Boolean!, address: String!, rank: Int!, challengeraddress: String): String! @resolver(name: "create_new_player")
createNewRanking(active: Boolean!, rankingname : String!, rankingdesc : String, rankingowneraddr : String!): String! @resolver(name: "create_new_ranking")
createNewUserJoinedRanking(active: Boolean!, rankingid : String!, rankingname : String!, rankingowneraddr : String!): String! @resolver(name: "create_new_userjoinedranking")
}
type Query {
allUserNames: [String!]! @resolver(name: "all_user_names")
allPlayerAddresses: [String!]! @resolver(name: "all_player_addresses")
allPlayerRanks: [Int!]! @resolver(name: "all_player_ranks")
allPlayerChallengerAddresses: [String!]! @resolver(name: "all_player_challenger_addresses")
allPlayers: [Player] @resolver(name: "all_players")
allRankings: [Ranking] @resolver(name: "all_rankings")
allUserJoinedRanking: [UserJoinedRanking] @resolver(name: "all_userjoinedranking")
allTodos: [Todo!]
todosByCompletedFlag(completed: Boolean!): [Todo!]
}
FQL for allTodos:
{
name: "allTodos",
unique: false,
serialized: true,
source: "Todo"
}
If I run the query from the GQL quickstart in Playground:
query FindAllTodos {
allTodos {
data {
_id
title
completed
}
}
}
I get the expected data. For allRankings
however:
FQL:
{
name: "allRankings",
unique: false,
serialized: true,
source: "Ranking"
}
if I run the query from the tutorial:
query AllRankings {
allRankings {
data {
_id
rankingname
rankingowneraddr
}
}
}
In Playground this second query gives error:
{
"data": null,
"errors": [
{
"message": "Cannot query field 'data' on type 'Ranking'. (line 3, column 5):\n data {\n ^",
"locations": [
{
"line": 3,
"column": 5
}
]
}
]
}
The only apparent difference (apart from the ! after Todo in schema which isnāt affecting the successful FindAllTodos query if I remove/leave it) is that allRankings is associated
with a resolver (@resolver(name: āall_rankingsā)).
The all_rankings resolver is defined in FQL as:
{
name: "all_rankings",
role: null,
body: Query(Lambda([], Select("data", Paginate(Match(Index("allRankings"))))))
}
Why do I get an error with the AllRankings query and not with the FindAllTodos query? thanks ā¦