Skip to content

Commit

Permalink
feat: add entity fetcher for game
Browse files Browse the repository at this point in the history
  • Loading branch information
llucasreis committed Aug 23, 2021
1 parent eb6cd7e commit 705d133
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.llucasreis.gamedgs.datafetchers;

import java.util.List;
import java.util.Map;

import com.llucasreis.gamedgs.domain.entities.Game;
import com.llucasreis.gamedgs.repositories.GameRepository;
import com.netflix.graphql.dgs.DgsComponent;
import com.netflix.graphql.dgs.DgsQuery;
import com.netflix.graphql.dgs.*;

import org.springframework.beans.factory.annotation.Autowired;

Expand All @@ -24,5 +24,12 @@ public List<Game> games() {
return this.gameRepository.findAll();
}

@DgsEntityFetcher(name = "Game")
public Game game(Map<String, Object> values) {
Long id = Long.parseLong((String) values.get("id"));

return this.gameRepository.findById(id).orElse(null);
}


}

0 comments on commit 705d133

Please sign in to comment.