-
-
Notifications
You must be signed in to change notification settings - Fork 167
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
GraphQL: Cannot query field "alignments" on type "Monster" #358
Comments
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 for example, we have a defintion for armor class
and then we have the slightly different monster variety
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 i think there's a couple options
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 in the current schema the alignment field on the |
It looks like the swagger openapi spec never caught up with this change which is tripping up a generated typescript client I've made 😢 If it's a simple as updating alignments:
description: "A creature's general moral and personal attitudes."
type: string
enum:
- chaotic neutral
- chaotic evil
- chaotic good
- lawful neutral
- lawful evil
- lawful good
- neutral
- neutral evil
- neutral good
- any alignment
- unaligned |
@mlupton100 Please feel free to open a PR! |
@mlupton100 where are you generating your typescript client from? Where does the spec not match reality? The alignment stuff is a bit unique because on the The
|
@ecshreve in this case I'm only referring to the flavour text on a monster, which comes from monster-model. This doesn't match up with what we actually receive from the API. In the schema this property is called So to be clear the only issue is with the name of the property, not the types themselves. It just leaves the generated client in a place where it shouts at me for trying to access FYI the generator I was using was # bundle the swagger file
npm run bundle-swagger
# generate the a typescript client with axios
npx @openapitools/openapi-generator-cli generate -i ./src/swagger/dist/openapi.json -g typescript-axios -o ./5e-srd-api-client/generated Also apologies for not raising a PR for this earlier this week. Life got in the way and I forgot all about this. If you're happy that what I've said actually makes sense I can go ahead and do that this evening. |
@mlupton100 ah! that totally makes sense. Fixing that typo should do the trick. While we're here, I think we should either update the enum to include all the possible values, or remove the enum entirely and just leave it as a string. Thoughts? It's just a plain string in the API typedef. 5e-srd-api/src/models/monster/types.d.ts Line 160 in 470d726
|
@ecshreve In my use case it doesn't really matter, but perhaps other people might want to pivot on this value. In which case capturing the possible values in an enum might be handy. if (monster.alignment === MonsterAlignmentEnum.ChaoticNeutral) {
// do a thing
} That's the only thing that comes to mind. |
I think in that case the For example, this monster returns Removing the |
I think just |
Tackling this and some other openapi schema things over in #619 |
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
andalignment
).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.
The text was updated successfully, but these errors were encountered: