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

Go Tutorial it's broken #1471

Open
mdmourao opened this issue Jun 3, 2023 · 1 comment
Open

Go Tutorial it's broken #1471

mdmourao opened this issue Jun 3, 2023 · 1 comment

Comments

@mdmourao
Copy link

mdmourao commented Jun 3, 2023

Hi!

Multiple Issues:
1.

go run github.com/99designs/gqlgen init

This command will create a completely different code from the one used in the tutorial.

Created:

srv := handler.NewDefaultServer(graph.NewExecutableSchema(graph.Config{Resolvers: &graph.Resolver{}}))

http.Handle("/", playground.Handler("GraphQL playground", "/query"))
http.Handle("/query", srv)

log.Printf("connect to http://localhost:%s/ for GraphQL playground", port)
log.Fatal(http.ListenAndServe(":"+port, nil))

Expected:
https://www.howtographql.com/graphql-go/6-authentication/

import (
hackernews "github.com/glyphack/go-graphql-hackernews"
)
(...)
router := chi.NewRouter()
server := handler.NewDefaultServer(hackernews.NewExecutableSchema(hackernews.Config{Resolvers: &hackernews.Resolver{}}))
router.Handle("/", playground.Handler("GraphQL playground", "/query"))
router.Handle("/query", server)

log.Printf("connect to http://localhost:%s/ for GraphQL playground", port)
log.Fatal(http.ListenAndServe(":"+port, router))

This issue will allow us to do the tutorial up to Authentication.

On the authentication, we need to add a middleware to the server and the code will not work.

At this moment we will try to change the code to the code shown on the examples (the expected version).

But the problem is that:

The import: hackernews "github.com/glyphack/go-graphql-hackernews" used on the server will redirect to: "https://github.com/Glyphack/graphql-golang" and this project defines its modules as github.com/glyphack/graphlq-golang.

We have a small typo: graphlq vs graphql.

This will lead to major frustration trying to deal with broken packages instead of focusing on learning GraphQl.

@Glyphack
Copy link
Member

I tried to update this guide here but we are short on maintainers. I'm not sure if it's possible to keep this fully updated. Maybe you can check this PR here, and also use the Glyphack/graphql-golang it is updated more regularly.

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

No branches or pull requests

2 participants