5e-srd-api
5e-srd-api copied to clipboard
GraphQL: Cannot query field "alignments" on type "Monster"
I was looking for the monster alignment data, and found it in the REST API, but I'm not seeing it in the GraphQL (I tried alignments and alignment).
I can try to dig into this myself this week, but I wanted to post the issue first, in case I'm missing something obvious.
This definitely looks like a legitimate flaw in the GraphQL schema. A PR would be most welcome!
ahh nice catch, poked around a bit and i think i have a handle on what's going on. this stems from Monster field definitions all being slightly different from the comparable Race and Class fields
for example, we have a defintion for armor class
type ArmorClass {
base: Int!
dex_bonus: Boolean!
max_bonus: Int
}
and then we have the slightly different monster variety
type: MonsterArmorClassType!
desc: String
value: Int!
armor: [Armor]
spell: Spell
condition: Condition
}
in the case of alignments, we have a defnition that returns an Alignment object, but if we look at the Monster schema in the database or the rest api, we can see that the Monster.alignment field is only a primitive string.
i think there's a couple options
- add an enum definition for
MonsterAlignment, and have the gql query formonster.monster-alignmentreturn the simple string val OR - update the monster schema to return an Alignment
i'm going to try and get a PR up for that first option this afternoon
The second option definitely seems more appealing to me! There seems almost no point in having an Alignments collection if we don't reference it from Monster documents.
i lied a little bit by accident.
in the gql schema , we currently only return the Alignment object on root root queries, and from the IdealOption type.
in the current schema the alignment field on the Race type, a primitive string 🤔 going to think about this a little more
oh yeah i made it way more complicated than it was. we should be able to get the string exposed real easy, but if we want to return an Alignment object instead it's a bit more work
localhost