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

Question: DataFetcher and RuntimeWiring vs GraphQLQueryResolver #4

Closed
SnuK87 opened this issue Jul 12, 2019 · 3 comments
Closed

Question: DataFetcher and RuntimeWiring vs GraphQLQueryResolver #4

SnuK87 opened this issue Jul 12, 2019 · 3 comments

Comments

@SnuK87
Copy link

SnuK87 commented Jul 12, 2019

I just started with graphql and have a question about this tutorial.

I don't really see the purpose of the GraphQLProvider class. Especially the method buildWiring(). As far as I can see the graphql-spring-boot-starter is doing the initialization and wiring automagically.

The following code is working fine for me:

@Component
@RequiredArgsConstructor
public class Query implements GraphQLQueryResolver {

	private final AuthorRepository authorRepo;
	private final BookRepository bookRepo;

    public Author getAuthor(Long id) {
    	return authorRepo.findById(id).orElse(null);
    }

    public Book getBook(Long id) {
    	return bookRepo.findById(id).orElse(null);
    }
}

Is there any benift of defining the DataFetchers manually? Or is this tutorial just outdated?

@ualter
Copy link

ualter commented Oct 2, 2019

Yes, perhaps it is outdated, here https://dzone.com/articles/a-beginners-guide-to-graphql-with-spring-boot another tutorial, more updated using the technique you described.

@Marx2
Copy link

Marx2 commented Apr 8, 2020

While I agree that this tutorial is outdated, I don't agree that manual wiring has no sense. It's not possible to make async resolvers.

@dondonz
Copy link
Member

dondonz commented Sep 29, 2023

Closing this old issue as since the tutorial has been updated to use Spring for GraphQL

@dondonz dondonz closed this as completed Sep 29, 2023
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

5 participants
@Marx2 @SnuK87 @ualter @dondonz and others