apollo-kotlin icon indicating copy to clipboard operation
apollo-kotlin copied to clipboard

Generated test builders calls resolve without enum list

Open anderssandven opened this issue 3 years ago • 1 comments

Summary

When generating test builders the generated code is invalid as it calls MapBuilder#resolve that requires a list of enum values. The generated code looks like this:

Example 1: 
public override fun build(): Map<String, Any?> = mapOf(
      "myType" to resolve("myType",
          MyType.type.notNull().list().notNull(), { myType() }),
    )

   
Example 2:
    public override fun build(): Map<String, Any?> = mapOf(
      "myTypeField" to resolve("myTypeField", CompiledStringType),
    )

Version

3.5.0 and main. Havent checked earlier versions

Steps to reproduce the behavior

  • Generate test builders for your schema

Let me know if you need more info. I tried fixing it, but gradle is difficult to make work properly so this report will suffice :)

anderssandven avatar Aug 11 '22 12:08 anderssandven

Thanks for sending this 🙏 . We're currently hard at work reworking these builders as they have a few shortcomings as you just found out. The work is tracked in https://github.com/apollographql/apollo-kotlin/issues/4016. If you feel like it, the latest SNAPSHOTs have a preliminary version of the new APIs that you can enable with generateDataBuilders:

apollo {
  generateDataBuilders.set(true)
}

Documentation is not written yet but feel free to follow up in that thread and we'll be happy to guide you through the new API.

martinbonnin avatar Aug 11 '22 12:08 martinbonnin

Closing for now as the schema based data builders have been available. Don't hesitate to re-open if needed!

BoD avatar Nov 03 '22 18:11 BoD