Skip to content

Commit

Permalink
fix: update TvShow type in pages.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
martapanc committed Aug 23, 2023
1 parent edb0458 commit 28e1007
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/app/(public)/about/free-time/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async function queryVideoGames() {
return flattenToArray<VideoGame>(data.videoGames);
}

export async function queryRandomFacts(query: DocumentNode) {
async function queryRandomFacts(query: DocumentNode) {
const { data } = await apolloClient.query({ query });

return flattenToArray<RandomFact>(data.randomFacts);
Expand Down
11 changes: 10 additions & 1 deletion src/pages/api/random-facts.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { DocumentNode } from 'graphql/language';
import { NextApiRequest, NextApiResponse } from 'next';

import { flattenToArray } from '@/lib/graphqlUtils';
import { shuffleArray } from '@/lib/helper';

import { queryRandomFacts } from '@/app/(public)/about/free-time/page';
import {
falseRandomFactsQueryQL,
selectedTrueRandomFactsQueryQL,
} from '@/queries/random-facts';

import apolloClient from '../../../apollo/apollo-client';

import { RandomFact } from '@/types/RandomFact';

const randomFactsApi = async (req: NextApiRequest, res: NextApiResponse) => {
Expand All @@ -28,4 +31,10 @@ const randomFactsApi = async (req: NextApiRequest, res: NextApiResponse) => {
});
};

async function queryRandomFacts(query: DocumentNode) {
const { data } = await apolloClient.query({ query });

return flattenToArray<RandomFact>(data.randomFacts);
}

export default randomFactsApi;

0 comments on commit 28e1007

Please sign in to comment.