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

AddTypeExtension vs AddType #31

Closed
gojanpaolo opened this issue Jan 10, 2021 · 3 comments · Fixed by #35
Closed

AddTypeExtension vs AddType #31

gojanpaolo opened this issue Jan 10, 2021 · 3 comments · Fixed by #35

Comments

@gojanpaolo
Copy link
Contributor

In 4-schema-design, AddTypeExtension and AddType is used interchangeably. I'm curious as well as confused because of this. I'll probably be able to clarify this later when I get to learn more about graphql and hc. But any response will be greatly appreciated.

e.g.

  1. Head back to the Startup.cs and add the TrackMutations to the schema builder.
  services
      .AddGraphQLServer()
      .AddQueryType(d => d.Name("Query"))
          .AddTypeExtension<SpeakerQueries>()
      .AddMutationType(d => d.Name("Mutation"))
          .AddTypeExtension<SessionMutations>()
          .AddTypeExtension<SpeakerMutations>()
          .AddTypeExtension<TrackMutations>()
      .AddType<AttendeeType>()
      .AddType<SessionType>()
      .AddType<SpeakerType>()
      .AddType<TrackType>()
      .EnableRelaySupport()
      .AddDataLoader<SpeakerByIdDataLoader>()
      .AddDataLoader<SessionByIdDataLoader>();

  1. Again, head over to the Startup.cs and register the TrackQueries with the schema builder.

    services
         .AddGraphQLServer()
         .AddQueryType(d => d.Name("Query"))
             .AddType<SessionQueries>()
             .AddType<SpeakerQueries>()
             .AddType<TrackQueries>()
         .AddMutationType(d => d.Name("Mutation"))
             .AddType<SessionMutations>()
             .AddType<SpeakerMutations>()
             .AddType<TrackMutations>()
         .AddType<AttendeeType>()
         .AddType<SessionType>()
         .AddType<SpeakerType>()
         .AddType<TrackType>()
         .EnableRelaySupport();
@michaelstaib
Copy link
Member

So, they actually can be used both ... we are however diverting to use AddTypeExtension to be more semantically correct. There might still be old code examples in the workshop that use AddType instead of AddTypeExtension.

Do you want to do a pull-request?

@gojanpaolo
Copy link
Contributor Author

@michaelstaib sure 👍

@michaelstaib
Copy link
Member

Awesome! Thanks for your help on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants