absinthe icon indicating copy to clipboard operation
absinthe copied to clipboard

Default values not rendered in the sdl

Open SvenW opened this issue 2 years ago • 4 comments

When specifying default values in input arguments they aren't rendered in the sdl, using Absinthe.Schema.to_sdl

SvenW avatar Oct 08 '21 10:10 SvenW

I think we should identify the source of the problem first... It seems like perhaps it's a difference between SDL & Macro schemas.

SDL schema does correctly render default values:

  • https://github.com/absinthe-graphql/absinthe/blob/master/test/absinthe/schema/sdl_render_test.exs#L48

Macro schema doesn't render default values:

  • https://github.com/absinthe-graphql/absinthe/blob/master/test/absinthe/schema/sdl_render_test.exs#L198
  • https://github.com/absinthe-graphql/absinthe/blob/master/test/absinthe/schema/sdl_render_test.exs#L254

This is probably another situation where the SDL & Macro schemas generate different structs when they are compiled.

binaryseed avatar Oct 08 '21 20:10 binaryseed

I think we should identify the source of the problem first... It seems like perhaps it's a difference between SDL & Macro schemas.

SDL schema does correctly render default values:

  • https://github.com/absinthe-graphql/absinthe/blob/master/test/absinthe/schema/sdl_render_test.exs#L48

Macro schema doesn't render default values:

  • https://github.com/absinthe-graphql/absinthe/blob/master/test/absinthe/schema/sdl_render_test.exs#L198
  • https://github.com/absinthe-graphql/absinthe/blob/master/test/absinthe/schema/sdl_render_test.exs#L254

This is probably another situation where the SDL & Macro schemas generate different structs when they are compiled.

Ok, so what's the way forward here. Are you guys digging in to the issue? Can I help in some way?

SvenW avatar Oct 11 '21 13:10 SvenW

I do not have time to dive into this, so @SvenW if you have time to look at the blueprints generated by both SDL and regular schemas that'd be the place to start.

benwilson512 avatar Oct 12 '21 23:10 benwilson512

So I've started to dig into this a little bit. import_sdl in the schema notation works with the language definition structs running the draft protocol https://github.com/absinthe-graphql/absinthe/blob/master/lib/absinthe/schema/notation/sdl.ex#L16 which generates blueprint types with correct default values default_value_blueprint is actually populated, this is not the case for macrobased schemas, it skips this part completely. Not sure how I should go forward here in a good way. It would be nice if the same protocol would be run in both cases so that the spec looks the same. Do you have any more pointers here, should I try to implement the draft protocol for all blueprint structs as well and not just the language structs? @benwilson512 @binaryseed

SvenW avatar Oct 15 '21 09:10 SvenW