Created
November 20, 2017 04:28
-
-
Save nwillc/09711658d71bc6765b5bb25a3b7e53ba to your computer and use it in GitHub Desktop.
DataFetcher to get a Company from a Map
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CompanyQuery implements DataFetcher<Company> { | |
private final Map<String, Company> companies; | |
public CompanyFetcher(Map<String, Company> companies) { | |
this.companies = companies; | |
} | |
@Override | |
public Company get(DataFetchingEnvironment environment) { | |
return companies.get(environment.getArgument("name")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment