aerogear / graphql-link

graphql-link is a GraphQL server that composes other GraphQL or OpenAPI endpoints
https://aerogear.github.io/graphql-link
Other
38 stars 8 forks source link

Using internal examples instead of remote ones #51

Open lmnzx opened 3 years ago

lmnzx commented 3 years ago

This is the entire output when I try to run the main.go file.

❯ go run main.go serve --verbose skipping Query.getSunDailyForecastByGeocode field respose, not an integer: default skipping Query.getSunDailyForecastByLocation field respose, not an integer: default 2021/02/17 20:16:36 loaded previously stored schema: upstreams/anilist.graphql 2021/02/17 20:16:36 downloading schema for upstream pokemon: https://graphql-pokemon.now.sh 2021/02/17 20:16:36 download failed: unexpected end of JSON input 2021/02/17 20:16:36 loaded previously stored schema: upstreams/weather.graphql panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x9dfcfa]

goroutine 1 [running]: github.com/aerogear/graphql-link/internal/gateway.getSelectedFields(0x0, 0xc001037140, 0xc001249170, 0x0, 0x0, 0xc000288188, 0x0, 0x1) /home/snxk/Projects/graphql-link/internal/gateway/gateway.go:330 +0x3a github.com/aerogear/graphql-link/internal/gateway.mount(0xc0001132d0, 0xc000282de0, 0xc000282c00, 0xc00029a320, 0xc000296288, 0x7, 0x0, 0x0, 0x0, 0x0, ...) /home/snxk/Projects/graphql-link/internal/gateway/mount.go:81 +0xc9 github.com/aerogear/graphql-link/internal/gateway.actionRunner.mount(0xc0001132d0, 0xc000282de0, 0xc000282c00, 0xc00029a320, 0xc00028ca00, 0x0, 0x0) /home/snxk/Projects/graphql-link/internal/gateway/mount.go:34 +0x19e github.com/aerogear/graphql-link/internal/gateway.New(0xbc6db5, 0x1, 0xc0000cf630, 0x100, 0xc0002826f0, 0x0, 0xc000290300, 0x3, 0x3, 0x0, ...) /home/snxk/Projects/graphql-link/internal/gateway/gateway.go:176 +0x826 github.com/aerogear/graphql-link/internal/cmd/serve.mountGatewayOnHttpServer(0xc000290400, 0xc, 0x13362a0) /home/snxk/Projects/graphql-link/internal/cmd/serve/cmd.go:223 +0x7e github.com/aerogear/graphql-link/internal/cmd/serve.startServer(0xc000290400, 0xc000290400, 0x0) /home/snxk/Projects/graphql-link/internal/cmd/serve/cmd.go:198 +0x9f github.com/aerogear/graphql-link/internal/cmd/serve.run(0x16e8420, 0xc000286100, 0x0, 0x1) /home/snxk/Projects/graphql-link/internal/cmd/serve/cmd.go:80 +0xe5 github.com/spf13/cobra.(Command).execute(0x16e8420, 0xc0002860f0, 0x1, 0x1, 0x16e8420, 0xc0002860f0) /home/snxk/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:846 +0x2c2 github.com/spf13/cobra.(Command).ExecuteC(0x16e8180, 0xa5d12a, 0x0, 0x16e86c0) /home/snxk/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:950 +0x375 github.com/spf13/cobra.(*Command).Execute(...) /home/snxk/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:887 github.com/aerogear/graphql-link/internal/cmd/root.Main() /home/snxk/Projects/graphql-link/internal/cmd/root/cmd.go:35 +0x3f github.com/aerogear/graphql-link/internal/cmd.Main(...) /home/snxk/Projects/graphql-link/internal/cmd/cmd.go:18 main.main() /home/snxk/Projects/graphql-link/main.go:13 +0xad exit status 2

ankithans commented 3 years ago

@snxk 2021/02/17 20:16:36 downloading schema for upstream pokemon: https://graphql-pokemon.now.sh Actually, I also tried using it and this GraphQL Endpoint https://graphql-pokemon.now.sh doesn't exist now! That's why it's throwing the error ig!

lmnzx commented 3 years ago

@ankithans you are right, I changed it to a working API and it works perfectly. Can the default graphql-link.yaml be changed to avoid the issues?

wtrocki commented 3 years ago

@ankithans Amazing! Yes. API's come and go. I think we can either

1) look for other API's to have as an example 2) Use something like graphql-serve to create graphql API on the fly 3) use examples (we probably need to bring examples outside the internal directory and have separate builds)

GraphQL-serve is done in node.js which will require an extra stack. Other API can also go down. My personal take is to have separate example server API build and use it in examples.

wtrocki commented 3 years ago

@snxk This is why I asked to create the issue. We can have a good conversation and see if we can take some path forward.

I think design uses an internal folder but I would not actually make things internal here and let examples to reuse some of the elements: https://github.com/aerogear/graphql-link/tree/master/internal/gateway/examples

ankithans commented 3 years ago

yeah @wtrocki, so we need to deploy an example graphql server (while using the above elements), right?

lmnzx commented 3 years ago

we can have a graphql server with mock data on a Heroku free tier, as an example.

wtrocki commented 3 years ago

no need to deploy. someone can run it on local machine.

additional problem is that if your api doesnt work error message is not great:

2021/02/17 20:16:36 download failed: unexpected end of JSON input

ankithans commented 3 years ago

Okay, will work on the example first!

wtrocki commented 3 years ago

Yep. This is good to learn golang as well.

ankithans commented 3 years ago

yes, will learn while implementing!