microsoft / microsoft/cppgraphqlgen

Failed to generate optionalNonNullArg of enum type

Open
#350 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
350
Forks
56
Avg merge
2h 33m
Merged PRs (30d)
3

Description

Hi, I tried using optionalNonNullArg as shown here: https://spec.graphql.org/October2021/#sel-JALTFFTB6CABABSnoI with enum type but schemagen failed with

terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at

Code sample to reproduce

enum optionalNonNullEnum {
	One
	Two
}

type optionalNonNullTest_1 {
	test(arg: optionalNonNullEnum! = One) : Boolean!
}

Same error goes for custom input type:

input optionalNonNullInput {
	testField: Int!
}

type optionalNonNullTest_2 {
	test(arg: optionalNonNullInput! = {testField: 1}) : Boolean
}

Boolean/Int/String works fine.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure in schemagen with the enum and custom input examples from the issue, then compare them with the Boolean, Int, and String cases that work. Trace the handling of optional non-null default values and confirm done when both examples generate without the std::out_of_range exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.