The id provided is too large

I have a mutation:

mutation {
  createPlayer(
    data: {
      rank: 1
      ranking: { connect: "283315189344895493" }
      challenger: { connect: "" }
    }
  ) {
    _id
  }
}

Which gives me the error:

The id provided is too large:
  1. What does this mean?
  2. Why do I get this?
  3. What should I do to fix it?
    Thanks …

Hi @FreeRoss,

may you post your GraphQL schema?

Thanks,
Luigi

Hi @Luigi_Servini
Here it is:

type User {
active: Boolean!
username: String!
description: String
email: String
mobile: String
playedAs: [Player!]! @relation
}

type Player {
rank: Int!
ranking: Ranking @relation
challenger: User! @relation
}

type Ranking {
active: Boolean!
rankingname: String!
rankingdesc: String
player: Player
}

type Mutation {
  
  createNewRanking(active: Boolean!, rankingname : String!, rankingdesc : String, rankingownerid : String!): Ranking! @resolver(name: "create_new_ranking")
  createNewUser(active: Boolean!, username : String!, password : String!, description: String, email: String, mobile: String): loginResult! @resolver(name: "create_new_user")
  loginUser(username: String!, password: String!): loginResult! @resolver(name: "login_user")
}

type Query {
  allUserNames: [String!]! @resolver(name: "all_user_names")
  allPlayerUIDs: [String!]! @resolver(name: "all_player_uids")
  allPlayerRanks: [Int!]! @resolver(name: "all_player_ranks")
  allPlayerChallengerUIDs: [String!]! @resolver(name: "all_player_challenger_uids")
  allPlayers: [Player] @resolver(name: "all_players")
  allRankings: [Ranking] @resolver(name: "all_rankings")
  allUsers: [User] @resolver(name: "all_users")
  gotPlayersByRankingId (rankingid: String!): [Player] @resolver(name: "got_players_byrankingid")
  gotRankingIdsByPlayer (uid: String!): [String] @resolver(name: "got_rankings_byplayerid")
}

type loginResult @embedded
{
  token : String
  logginUser : User
}

Thanks, Philip

Hi @FreeRoss,

the problematic part is

 challenger: { connect: "" }

You cannot use connect with an empty string.
Not sure what’s your goal using connect with no id, but I’m happy to discuss about it.

Luigi

Hi @Luigi_Servini

I’m attempting to get to grips with relations as suggested by @ptpaterson.

I inserted a reference to an existing player doc where previously the string was empty (above) and the api (Playground) did then create a new player document in the Player collection.

However, the new doc doesn’t have a ranking field, despite ‘ranking: { connect: “283315189344895493” }’ (an existing doc) in the createPlayer mutation definition.

Also, the reason I had left the ‘challenger: { connect: “” }’ field blank was that, in my app design, a player will often have no challenger i.e. they will be ‘Available’ (ready to challenge).

  1. Why was no ‘ranking’ field created in the Player doc?

  2. Can I represent ‘Available’ with this schema (and these relations) or do I need to update it (and in that case, to what?)?

Thanks for your help …

Check the Ranking Document you linked to. In a one-to-one relationship the reference is only stored in one Collection and an index is used to access the back-relation. Fauna chooses which a collection to store the reference by alphabetical order of the title of the Collection… not the greatest IMO but it is consistent.

If you want to leave it blank then leave it blank and no connection will be made. You should remove the exclamation that marks the field as required.

Thanks @ptpaterson
I removed the ! from the challenger: User @relation
so my schema is now:

type User {
active: Boolean!
username: String!
description: String
email: String
mobile: String
playedAs: [Player!]! @relation
}

type Player {
rank: Int!
ranking: Ranking! @relation
challenger: User @relation
}

type Ranking {
active: Boolean!
rankingname: String!
rankingdesc: String
player: Player
}

type Mutation {
  
  createNewRanking(active: Boolean!, rankingname : String!, rankingdesc : String, rankingownerid : String!): Ranking! @resolver(name: "create_new_ranking")
  createNewUser(active: Boolean!, username : String!, password : String!, description: String, email: String, mobile: String): loginResult! @resolver(name: "create_new_user")
  loginUser(username: String!, password: String!): loginResult! @resolver(name: "login_user")
}

type Query {
  allUserNames: [String!]! @resolver(name: "all_user_names")
  allPlayerUIDs: [String!]! @resolver(name: "all_player_uids")
  allPlayerRanks: [Int!]! @resolver(name: "all_player_ranks")
  allPlayerChallengerUIDs: [String!]! @resolver(name: "all_player_challenger_uids")
  allPlayers: [Player] @resolver(name: "all_players")
  allRankings: [Ranking] @resolver(name: "all_rankings")
  allUsers: [User] @resolver(name: "all_users")
  gotPlayersByRankingId (rankingid: String!): [Player] @resolver(name: "got_players_byrankingid")
  gotRankingIdsByPlayer (uid: String!): [String] @resolver(name: "got_rankings_byplayerid")
}

type loginResult @embedded
{
  token : String
  logginUser : User
}

In the api I tried some alternatives:

challenger: ""

which gives:

  "errors": [
    {
      "message": "Expected type 'PlayerChallengerRelation', found '\"\"'. (line 2, column 86):\n  createPlayer(data: {rank: 2, ranking: {connect: \"283315189344895493\"}, challenger: \"\"}) {\n 

and
remove ‘challenger:’ completely:
This creates a Player document but only with a rank field . There is no ranking field (although it’s marked as ‘required’ in the schema)) and no challenger field (but the app requires a challenger field to exist, just with no value until a challenge is made).

  1. How should I represent an ‘Available’ challenger here?
  2. Why does the ranking field disappear together with the challenger field, when no challenger field is specified in the api function?
    thanks for your help …