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

fix(graphql): ListCooccurrences API error #346

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/graphql/queries/ListCooccurrences.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ export default {
},
async resolve(rootValue, { orderBy = [], filter = {}, ...otherParams }) {
const body = {
sort: getSortArgs(orderBy, {
vote: (o) => ({ score: { order: o } }),
}),
track_scores: true, // for _score sorting
sort: getSortArgs(orderBy),
};

const filterQueries = [];
Expand All @@ -51,7 +48,6 @@ export default {
body.query = {
bool: {
filter: filterQueries,
minimum_should_match: 1, // At least 1 "should" query should present
},
};

Expand Down
38 changes: 37 additions & 1 deletion src/graphql/queries/__tests__/ListCooccurrences.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import gql from 'util/GraphQL';
import { loadFixtures, unloadFixtures } from 'util/fixtures';
import fixtures from '../__fixtures__/ListCooccurrences';

describe('ListArticles', () => {
describe('ListCooccurrences', () => {
beforeAll(() => loadFixtures(fixtures));

it('lists all cooccurrences', async () => {
Expand Down Expand Up @@ -49,5 +49,41 @@ describe('ListArticles', () => {
).toMatchSnapshot('by updatedAt DESC');
});

it('filters', async () => {
expect(
await gql`
{
ListCooccurrences(
filter: { updatedAt: { GT: "2020-02-03T00:01:05.000Z" } }
) {
edges {
node {
id
updatedAt
}
}
totalCount
}
}
`()
).toMatchInlineSnapshot(`
Object {
"data": Object {
"ListCooccurrences": Object {
"edges": Array [
Object {
"node": Object {
"id": "listCooccurrenceTest2",
"updatedAt": "2020-02-03T00:02:00.000Z",
},
},
],
"totalCount": 1,
},
},
}
`);
});

afterAll(() => unloadFixtures(fixtures));
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ListArticles lists all cooccurrences 1`] = `
exports[`ListCooccurrences lists all cooccurrences 1`] = `
Object {
"data": Object {
"ListCooccurrences": Object {
Expand Down Expand Up @@ -28,7 +28,7 @@ Object {
}
`;

exports[`ListArticles sorts: by updatedAt DESC 1`] = `
exports[`ListCooccurrences sorts: by updatedAt DESC 1`] = `
Object {
"data": Object {
"ListCooccurrences": Object {
Expand Down
Loading