Skip to content
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

Render SDL #736

Merged
merged 65 commits into from
Aug 1, 2019
Merged

Render SDL #736

merged 65 commits into from
Aug 1, 2019

Conversation

binaryseed
Copy link
Contributor

@binaryseed binaryseed commented May 24, 2019

This PR adds the ability to render out Blueprint structs as GraphQL SDL.

If you have a blueprint struct, you may view it's SDL by inspecting it with the :pretty flag:

IO.inspect(blueprint, pretty: true)

From the command line, you can invoke a Mix Task generate a .graphql file:

mix absinthe.schema.sdl --schema MySchema

@binaryseed binaryseed marked this pull request as ready for review May 31, 2019 16:27
@binaryseed
Copy link
Contributor Author

binaryseed commented Jun 5, 2019

  • multi-line descriptions need correct indentation

@benwilson512
Copy link
Contributor

Dude, this is awesome. 😍

@binaryseed
Copy link
Contributor Author

  • directive locations can break to multiline

@bruce
Copy link
Contributor

bruce commented Jun 13, 2019

@binaryseed I think you're unblocked by the directive args issue now. 🎉

@binaryseed
Copy link
Contributor Author

I don't think it's quite there, I pushed a commit with enum_value missing in one location, and I'm not seeing the deprecation getting attached to the schema node...

Looks like some of the functions in AttachDirectives aren't actually used?

@bruce
Copy link
Contributor

bruce commented Jun 14, 2019

AttachDirectives shouldn't actually be necessary at all, now that Absinthe.Phase.Schema is being used to apply schema_node entries. I've pushed a commit to master removing it from the pipeline.

That said, this test was even passing before, and I'm seeing the deprecation attached as I expect:

%Absinthe.Type.Field{
  __private__: [],
  __reference__: %{
    location: %{
      file: "/Users/bruce/code/absinthe-graphql/absinthe/test/absinthe/schema/notation/experimental/import_sdl_test.exs",
      line: 23
    },
    module: Absinthe.Schema.Notation.Experimental.ImportSdlTest.Definition
  },
  args: %{},
  complexity: nil,
  config: nil,
  default_value: nil,
  definition: Absinthe.Schema.Notation.Experimental.ImportSdlTest.Definition,
  deprecation: %Absinthe.Type.Deprecation{reason: "Reason"},
  description: nil,
  identifier: :deprecated_field_with_reason,
  middleware: [{Absinthe.Middleware.MapGet, :deprecated_field_with_reason}],
  name: "deprecatedFieldWithReason",
  triggers: [],
  type: :string
}
.....

@binaryseed
Copy link
Contributor Author

I think the default_value SDL support still needs work...

Macro based schemas get raw elixir values for default_value, while SDL schemas get structs like Absinthe.Blueprint.Input.Enum when it goes through Blueprint.Draft.convert

This is easy to see when an Enum is used, since it causes a failure in a schema phase:

#754

@binaryseed binaryseed requested a review from bruce July 30, 2019 00:26
Copy link
Contributor

@bruce bruce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good to merge when you're ready, I just left a couple comments.

Might just want to pull that comment out to an issue, and it looks like you still have one unfinished checkbox on the PR.

test/absinthe/schema/sdl_render_test.exs Outdated Show resolved Hide resolved
test/mix/tasks/absinthe.schema.sdl_test.exs Show resolved Hide resolved
@binaryseed
Copy link
Contributor Author

Ready to go!

@binaryseed binaryseed merged commit 89e1eb5 into absinthe-graphql:master Aug 1, 2019
@binaryseed binaryseed deleted the sdl_render branch August 1, 2019 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants