Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue: Cannot return null for non-nullable field AttacksListItem.name #645

Open
2 of 4 tasks
notaphplover opened this issue Jan 29, 2025 · 2 comments · May be fixed by #655
Open
2 of 4 tasks

issue: Cannot return null for non-nullable field AttacksListItem.name #645

notaphplover opened this issue Jan 29, 2025 · 2 comments · May be fixed by #655
Labels
issue Possible Data Error or Server Bug server Server/API Related

Comments

@notaphplover
Copy link

notaphplover commented Jan 29, 2025

Where are you having the issue

  • GraphQL
  • JSON API

Is the issue affecting one of the two elements below ?

  • Translations
  • Definitions Files (Open API, GraphQL Schema, etc)

Description

When calling the API, a server error is thrown when AttacksListItem.name is null.

Recreation steps

Just send the following query:

{
  set(id: "sm10") @locale(lang: "en") {
    id,
    name,
    cards {
      abilities { effect, name, type },
      attacks { cost, damage, effect, name },
      category,
      effect,
      energyType,
      evolveFrom,
      hp,
      id,
      image,
      item { effect, name },
      legal { expanded, standard },
      level,
      name,
      rarity,
      regulationMark,
      resistances { type, value },
      retreat,
      stage,
      suffix,
      trainerType,
      types,
      variants { firstEdition, holo, normal, reverse, wPromo },
      weaknesses { type, value }
    }
  }
}

Expected behavior

API serves a set.

Current behavior

API fails with the folowing payload:

{
  "errors": [
    {
      "message": "Cannot return null for non-nullable field AttacksListItem.name.",
      "locations": [
        {
          "line": 13,
          "column": 39
        }
      ],
      "path": [
        "set",
        "cards",
        0,
        "attacks",
        3,
        "name"
      ]
    }
  ]
}

Context

https://www.apollographql.com/blog/using-nullability-in-graphql#what-happens-if-you-try-to-return-null-for-a-non-null-field

@notaphplover notaphplover added issue Possible Data Error or Server Bug server Server/API Related labels Jan 29, 2025
@notaphplover
Copy link
Author

notaphplover commented Jan 30, 2025

After having a look at the data, it seems the underlying issue is the lack of a fallback value when providing the attack name.

For example, consider https://github.com/tcgdex/cards-database/blob/master/data/Diamond%20%26%20Pearl/Majestic%20Dawn/65.ts:

Since their attacks names are only provided for the german language, the API fails to fetch that card:

{
  card(id: "dp5-65") @locale(lang: "en") {
    attacks { cost, damage, effect, name }
  }
}

This query fails but:

{
  card(id: "dp5-65") @locale(lang: "de") {
    attacks { cost, damage, effect, name }
  }
}

This one is successfull.

It would make a lot of sense to make this property nullable or provide a fallback value in this scenario

@Aviortheking
Copy link
Member

Aviortheking commented Feb 6, 2025

Hi, after looking more, the problem is coming from another area, Cards that contains an attack MUST (at least it is currecntly always the case) hase a name, so the GraphQL API is correctly configured.

If a card has one value in the correct language everything else should be filled.

After testing my database I found the erroneous cards

error compiling card sm10-1
error compiling card sm9-10
error compiling card sm8-19
error compiling card sm10-20
error compiling card sm115-29
error compiling card sm6-31
error compiling card sm11-35
error compiling card sm115-44
error compiling card sm9-51
error compiling card ex2-53
error compiling card sm11-54
error compiling card ex5-55
error compiling card sm5-58
error compiling card sm5-62
error compiling card dp5-65
error compiling card sm11-71
error compiling card sm6-74
error compiling card sm5-77
error compiling card ex4-79
error compiling card ex12-83
error compiling card ex12-84
error compiling card ex5-84
error compiling card ex4-84
error compiling card ex5-85
error compiling card ex12-86
error compiling card ex5-86
error compiling card hgss3-87
error compiling card ex12-87
error compiling card ex13-87
error compiling card hgss3-89
error compiling card sm5-89
error compiling card ex12-89
error compiling card hgss2-90
error compiling card hgss2-92
error compiling card hgss2-94
error compiling card pl2-95
error compiling card sm6-96
error compiling card hgss4-99
error compiling card hgss4-101
error compiling card sm10-107
error compiling card hgss1-111
error compiling card ecard1-112
error compiling card hgss1-113
error compiling card neo4-113
error compiling card ecard2-119
error compiling card sv04-120
error compiling card ecard2-121
error compiling card ecard2-122
error compiling card ecard2-124
error compiling card sm11-126
error compiling card ecard2-127
error compiling card ecard2-129
error compiling card ecard3-129
error compiling card sm10-130
error compiling card ecard3-130
error compiling card ecard3-131
error compiling card ecard2-132
error compiling card ecard3-133
error compiling card ecard3-134
error compiling card dp6-136
error compiling card ecard3-136
error compiling card dp6-137
error compiling card ecard2-140
error compiling card sm8-144
error compiling card ecard1-144
error compiling card sv03.5-152
error compiling card sv03.5-153
error compiling card sm8-154
error compiling card sv03.5-154
error compiling card sm10-191
error compiling card sm10-192
error compiling card sm10-194
error compiling card sm12-210
error compiling card sm12-211
error compiling card sm12-212
error compiling card sm12-214
error compiling card sm11-214
error compiling card sm12-215
error compiling card sm11-215
error compiling card sm12-216
error compiling card sm11-217
error compiling card sm11-218
error compiling card sm11-220
error compiling card sm11-221
error compiling card sm11-222
error compiling card sm12-223
error compiling card sm11-225
error compiling card sm11-226
error compiling card bwp-BW85
error compiling card dpp-DP03
error compiling card dpp-DP13
error compiling card smp-SM166
error compiling card smp-SM168
error compiling card smp-SM169
error compiling card smp-SM201
error compiling card xyp-XY154
error compiling card xyp-XY63
error compiling card xyp-XY87

I am currently fixing them manually and will update here when fixed !

@Aviortheking Aviortheking linked a pull request Feb 6, 2025 that will close this issue
92 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue Possible Data Error or Server Bug server Server/API Related
Projects
Status: Todo
2 participants