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 Item.name #647

Open
2 of 4 tasks
notaphplover opened this issue Jan 30, 2025 · 1 comment
Open
2 of 4 tasks

issue: Cannot return null for non-nullable field Item.name #647

notaphplover opened this issue Jan 30, 2025 · 1 comment
Labels
issue Possible Data Error or Server Bug server Server/API Related

Comments

@notaphplover
Copy link

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 Item.name is null.

Just send the following query:

{
  set(id: "dp5") @locale(lang: "en") {
    id,
    name,
    cards {
      abilities { effect, name, type },
      attacks { cost, damage, effect },
      category,
      effect,
      energyType,
      evolveFrom,
      hp,
      id,
      image,
      item { 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 Item.name.",
      "locations": [
        {
          "line": 20,
          "column": 14
        }
      ],
      "path": [
        "set",
        "cards",
        3,
        "item",
        "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 30, 2025
@mike7user
Copy link

I'm just finding this project, but your best option is to adjust the call to the field Item.name so if it holds a NULL value or an empty value to return an exception sp the system is comfortable with move past those instances without thinking it's an problem. I would avoid adding print statements for the exception because these instances of null or empty will happen a lot throughout the Pokémon tcg database. You have to run a test to see if it holds valid output. and adjust as needed. What file is it calling to and at what line? That's where you should add the exception. Then submit your findings.

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
Development

No branches or pull requests

2 participants