bramble icon indicating copy to clipboard operation
bramble copied to clipboard

Impossible to use as a library

Open aromancev opened this issue 3 years ago • 3 comments

Hi team,

I would like to use bramble as a library. It's currently impossible because some types are not exported.

  1. As per the docs, I should be able to implement bramble.Plugin without having to embed bramble.BasePlugin. This is currently impossible because bramble.queryExecution is not exported, but is present in the signature of bramble.Plugin.ModifyExtensions method.
  2. To create a custom main function, I need to create an instance of bramble.Gateway. This is impossible because neither bramble.newExecutableSchema nor bramble.ExecutableSchema.plugins are exported.

Could you please export the listed types/functions so bramble could be used as a library?

Thanks for the help!

aromancev avatar Feb 17 '22 16:02 aromancev

@joshiefu now that the two PRs are merged, would it be possible to post an example of how to use the project as a library? For example, would it be setting up a custom "main.go" that pulls in a different set of plugins and middleware?

sodabrew avatar Mar 14 '22 00:03 sodabrew

@sodabrew that is the idea, at Movio we already have a separate main.go that loads in some extra plugins which is essentially this:

package main

import (
	"github.com/movio/bramble"
	_ "github.com/movio/bramble/plugins"
	_ "github.com/movio/internal-repo/bramble/plugins"
)

func main() {
	bramble.Main()
}

That PR was the first in a few changes we want to make so it would be possible to add bramble as a http.Handler on a http.ServeMux.

We'll work on getting an example up as I think that would be useful.

pkqk avatar Mar 14 '22 00:03 pkqk

Related: https://github.com/movio/bramble/issues/98

gmac avatar Mar 16 '22 17:03 gmac