Khan / genqlient

a truly type-safe Go GraphQL client
MIT License
1.03k stars 99 forks source link

invalid character '<' looking for beginning of value #277

Closed talksik closed 1 year ago

talksik commented 1 year ago

Describe the bug Just a simple query for login not working. Seems to be an unmarshalling error.

To Reproduce Steps to reproduce the behavior. Please include whether the problem happens at code-generation time or at runtime. Hit our api https://api.flowy.live with the following query defined in genqlient.graphql. No auth required.

 mutation verifyCode ($phoneNumber: String!, $code: String!) {
  verifyCode(phoneNumber: $phoneNumber, code: $code) {
    user {
      id
      line
      phoneNumber
      isVerified
    }
    token
  }
}

Here is our client code.

    authResponse, err := verifyCode(ctx, client, "+17373145563", "123456")
    if err != nil {
        logrus.Fatal(err)
    }

Expected behavior It should not result in an error. It should give response as graphiql does without issue.

Additional context This was my first attempt at using this library. Is it maintained and is it enterprise ready? Or should I go with another open source one?

Also why are all the types and response types and functions private. That means we have to put it in main to use it in main.go, but we can't import and use the functions anywhere else in our client code.

Thank you!

talksik commented 1 year ago

Hey folks, fixed this. I am new to graphql so I put in the wrong url. When using 99designs graphqlggen, you want to make sure the url is not home / and instead points to the query endpoint /query

talksik commented 1 year ago

@benjaminjkraft Would you know the answer to the adjacent question? How do we make the generated types and functions public?

benjaminjkraft commented 1 year ago

genqlient will match the casing of your query, so just do mutation VerifyCode ...! We should probably document that somewhere better :-)

talksik commented 1 year ago

perfect awesome thanks @benjaminjkraft !