gqlgen icon indicating copy to clipboard operation
gqlgen copied to clipboard

Update eagerly fetching section

Open theverything opened this issue 2 years ago • 8 comments

This fixes the docs so that the generate command will correctly generate the User resolver.

Discussions about this can be found here https://github.com/99designs/gqlgen/discussions/2146 and here https://github.com/99designs/gqlgen/discussions/2144

I have:

  • [x] Updated any relevant documentation (see docs)

theverything avatar May 04 '22 21:05 theverything

This is not a solution. Please read carefully the docs and other issues and questions.

frederikhors avatar May 04 '22 23:05 frederikhors

This is not an issue at all.

frederikhors avatar May 04 '22 23:05 frederikhors

@frederikhors I'm not sure what you mean. The docs in the https://gqlgen.com/getting-started are incorrect, specifically the https://gqlgen.com/getting-started/#dont-eagerly-fetch-the-user. If you compare code snippets to the code in the completed tutorial here https://github.com/vektah/gqlgen-tutorials/tree/master/gettingstarted you can see that they are clearly different.

theverything avatar May 05 '22 00:05 theverything

Coverage Status

Coverage remained the same at 74.628% when pulling 47ab3e1c9c44801b95918017c7be2961dc785e12 on theverything:fix-getting-started-docs into 3228f36fec50930483801b27b92658592fab5e87 on 99designs:master.

coveralls avatar May 05 '22 21:05 coveralls

Can you compare your fix with #2157 and see if it addresses your concern fully?

StevenACoffman avatar May 16 '22 14:05 StevenACoffman

@StevenACoffman it does not. The PR does not address the issue properly nor does it address all of the issues.

Adding the resolver section to the gqlgen config is not necessary because once you update the Todo struct with the UserID instead of the User field, gqlgen will create the resolver for you.

This is not needed.

 Todo:
    fields:
      user:
        resolver: true

Its also missing the update the the CreateTodo function that is included in my PR.

theverything avatar May 16 '22 16:05 theverything

@theverything, in gqlgen there are two different ways to do this. And they are both in docs.

frederikhors avatar May 16 '22 16:05 frederikhors

@frederikhors @StevenACoffman After the user finishes the the tutorial their code should look exactly like the code in the link referenced in the tutorial itself. Found here

https://github.com/99designs/gqlgen/blob/master/docs/content/getting-started.md?plain=1#L15

@frederikhors I understand there is multiple ways to create a resolver but why have the user use both solutions when only one is necessary

theverything avatar May 16 '22 16:05 theverything

I was confused by the getting-started eager-fetching section as well. I came upon this PR while searching around to see if others were confused as well.

While searching around, this issue comment got me to look closer at the github README and see the explanation about the two different eager-fetching solutions. I haven't found this info yet on https://gqlgen.com docs. That particular README section and the link to the completed tutorial code cleared up this topic for me.

scottopherson avatar Nov 03 '22 23:11 scottopherson