Skip to content

Commit

Permalink
Expose FOS facets and filtering in Graphql
Browse files Browse the repository at this point in the history
  • Loading branch information
jrhoads committed Apr 12, 2023
1 parent 502a4a1 commit 0b3a2ab
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
4 changes: 4 additions & 0 deletions app/graphql/types/query_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ def actor(id:)
argument :has_views, Int, required: false
argument :has_downloads, Int, required: false
argument :field_of_science, String, required: false
argument :field_of_science_repository, String, required: false
argument :field_of_science_combined, String, required: false
argument :facet_count, Int, required: false, default_value: 10
argument :first, Int, required: false, default_value: 25
argument :after, String, required: false
Expand Down Expand Up @@ -1281,6 +1283,8 @@ def response(**args)
has_views: args[:has_views],
has_downloads: args[:has_downloads],
field_of_science: args[:field_of_science],
field_of_science_repository: args[:field_of_science_repository],
field_of_science_combined: args[:field_of_science_combined],
facet_count: args[:facet_count],
pid_entity: args[:pid_entity],
state: "findable",
Expand Down
27 changes: 13 additions & 14 deletions spec/graphql/types/work_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1270,19 +1270,18 @@
).to match_array([])
end

# Temporariliy disable these tests until gql/aggregates are enabled
# it "returns Field of Science Facets from the repository" do
# response = @facet_response
# expect(
# response.dig("data", "works", "fieldsOfScienceRepository")
# ).to match_array([ fos_facet ])
# end

# it "returns combined Field of Science Facets" do
# response = @facet_response
# expect(
# response.dig("data", "works", "fieldsOfScienceCombined")
# ).to match_array([ fos_facet ])
# end
it "returns Field of Science Facets from the repository" do
response = @facet_response
expect(
response.dig("data", "works", "fieldsOfScienceRepository")
).to match_array([ fos_facet ])
end

it "returns combined Field of Science Facets" do
response = @facet_response
expect(
response.dig("data", "works", "fieldsOfScienceCombined")
).to match_array([ fos_facet ])
end
end
end

0 comments on commit 0b3a2ab

Please sign in to comment.