From ab81df7f3d317281a05caec18e2cfd89dc26bc7a Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Tue, 28 Nov 2023 15:09:04 +0100 Subject: refactor(services): avoid nested fetchers If we use fetchPostsCount inside fetchAllPostsSlugs, we might have problems to test fetchAllPostsSlugs failure. So it is better to let the consumer pass the posts count as an argument. The same applies to thematics and topics. --- src/services/graphql/fetchers/topics/fetch-all-topics-slugs.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/services/graphql/fetchers/topics/fetch-all-topics-slugs.ts') diff --git a/src/services/graphql/fetchers/topics/fetch-all-topics-slugs.ts b/src/services/graphql/fetchers/topics/fetch-all-topics-slugs.ts index eab4a7c..1df0039 100644 --- a/src/services/graphql/fetchers/topics/fetch-all-topics-slugs.ts +++ b/src/services/graphql/fetchers/topics/fetch-all-topics-slugs.ts @@ -1,6 +1,5 @@ import type { GraphQLNodes, Nullable, SlugNode } from '../../../../types'; import { fetchGraphQL, getGraphQLUrl } from '../../../../utils/helpers'; -import { fetchTopicsCount } from './fetch-topics-count'; type TopicsSlugsResponse = { topics: Nullable>; @@ -17,14 +16,14 @@ const topicsSlugsQuery = `query TopicsSlugs($first: Int) { /** * Retrieve the WordPress topics slugs. * + * @param {number} count - The number of topics slugs to retrieve. * @returns {Promise} The topics slugs. */ -export const fetchAllTopicsSlugs = async (): Promise => { - const topicsCount = await fetchTopicsCount(); +export const fetchAllTopicsSlugs = async (count: number): Promise => { const response = await fetchGraphQL({ query: topicsSlugsQuery, url: getGraphQLUrl(), - variables: { first: topicsCount }, + variables: { first: count }, }); if (!response.topics) -- cgit v1.2.3 fstats
blob: b794fa93d8203198e3a431669f45c80416f78dfb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Prism.languages.r = {
  comment: /#.*/,
  string: {
    pattern: /(['"])(?:\\.|(?!\1)[^\\\r\n])*\1/,
    greedy: true,
  },
  'percent-operator': {
    // Includes user-defined operators
    // and %%, %*%, %/%, %in%, %o%, %x%
    pattern: /%[^%\s]*%/,
    alias: 'operator',
  },
  boolean: /\b(?:FALSE|TRUE)\b/,
  ellipsis: /\.\.(?:\.|\d+)/,
  number: [
    /\b(?:Inf|NaN)\b/,
    /(?:\b0x[\dA-Fa-f]+(?:\.\d*)?|\b\d+(?:\.\d*)?|\B\.\d+)(?:[EePp][+-]?\d+)?[iL]?/,
  ],
  keyword:
    /\b(?:NA|NA_character_|NA_complex_|NA_integer_|NA_real_|NULL|break|else|for|function|if|in|next|repeat|while)\b/,
  operator: /->?>?|<(?:=|<?-)?|[>=!]=?|::?|&&?|\|\|?|[+*\/^$@~]/,
  punctuation: /[(){}\[\],;]/,
};