Skip to content

Commit

Permalink
removed providers.js
Browse files Browse the repository at this point in the history
  • Loading branch information
leoloso committed Mar 26, 2024
1 parent 827ea30 commit 514e8bf
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 30 deletions.
6 changes: 2 additions & 4 deletions src/data/categories.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { WORDPRESS_GRAPHQL_PROVIDER_WPGRAPHQL, WORDPRESS_GRAPHQL_PROVIDER_GATOGRAPHQL } from './providers/providers';

import {
QUERY_ALL_CATEGORIES as WPGRAPHQL_QUERY_ALL_CATEGORIES,
QUERY_CATEGORY_BY_SLUG as WPGRAPHQL_QUERY_CATEGORY_BY_SLUG,
Expand All @@ -15,14 +13,14 @@ import {
const { WORDPRESS_GRAPHQL_PROVIDER } = process.env;

module.exports = {
...(WORDPRESS_GRAPHQL_PROVIDER === WORDPRESS_GRAPHQL_PROVIDER_WPGRAPHQL
...(WORDPRESS_GRAPHQL_PROVIDER === 'wpgraphql'
? {
QUERY_ALL_CATEGORIES: WPGRAPHQL_QUERY_ALL_CATEGORIES,
QUERY_CATEGORY_BY_SLUG: WPGRAPHQL_QUERY_CATEGORY_BY_SLUG,
QUERY_CATEGORY_SEO_BY_SLUG: WPGRAPHQL_QUERY_CATEGORY_SEO_BY_SLUG,
}
: {}),
...(WORDPRESS_GRAPHQL_PROVIDER === WORDPRESS_GRAPHQL_PROVIDER_GATOGRAPHQL
...(WORDPRESS_GRAPHQL_PROVIDER === 'gatographql'
? {
QUERY_ALL_CATEGORIES: GATOGRAPHQL_QUERY_ALL_CATEGORIES,
QUERY_CATEGORY_BY_SLUG: GATOGRAPHQL_QUERY_CATEGORY_BY_SLUG,
Expand Down
6 changes: 2 additions & 4 deletions src/data/menus.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { WORDPRESS_GRAPHQL_PROVIDER_WPGRAPHQL, WORDPRESS_GRAPHQL_PROVIDER_GATOGRAPHQL } from './providers/providers';

import { QUERY_ALL_MENUS as WPGRAPHQL_QUERY_ALL_MENUS } from './providers/wpgraphql/menus';

import { QUERY_ALL_MENUS as GATOGRAPHQL_QUERY_ALL_MENUS } from './providers/gatographql/menus';

const { WORDPRESS_GRAPHQL_PROVIDER } = process.env;

module.exports = {
...(WORDPRESS_GRAPHQL_PROVIDER === WORDPRESS_GRAPHQL_PROVIDER_WPGRAPHQL
...(WORDPRESS_GRAPHQL_PROVIDER === 'wpgraphql'
? {
QUERY_ALL_MENUS: WPGRAPHQL_QUERY_ALL_MENUS,
}
: {}),
...(WORDPRESS_GRAPHQL_PROVIDER === WORDPRESS_GRAPHQL_PROVIDER_GATOGRAPHQL
...(WORDPRESS_GRAPHQL_PROVIDER === 'gatographql'
? {
QUERY_ALL_MENUS: GATOGRAPHQL_QUERY_ALL_MENUS,
}
Expand Down
6 changes: 2 additions & 4 deletions src/data/pages.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { WORDPRESS_GRAPHQL_PROVIDER_WPGRAPHQL, WORDPRESS_GRAPHQL_PROVIDER_GATOGRAPHQL } from './providers/providers';

import {
PAGE_FIELDS as WPGRAPHQL_PAGE_FIELDS,
QUERY_ALL_PAGES_INDEX as WPGRAPHQL_QUERY_ALL_PAGES_INDEX,
Expand All @@ -21,7 +19,7 @@ import {
const { WORDPRESS_GRAPHQL_PROVIDER } = process.env;

module.exports = {
...(WORDPRESS_GRAPHQL_PROVIDER === WORDPRESS_GRAPHQL_PROVIDER_WPGRAPHQL
...(WORDPRESS_GRAPHQL_PROVIDER === 'wpgraphql'
? {
PAGE_FIELDS: WPGRAPHQL_PAGE_FIELDS,
QUERY_ALL_PAGES_INDEX: WPGRAPHQL_QUERY_ALL_PAGES_INDEX,
Expand All @@ -31,7 +29,7 @@ module.exports = {
QUERY_PAGE_SEO_BY_URI: WPGRAPHQL_QUERY_PAGE_SEO_BY_URI,
}
: {}),
...(WORDPRESS_GRAPHQL_PROVIDER === WORDPRESS_GRAPHQL_PROVIDER_GATOGRAPHQL
...(WORDPRESS_GRAPHQL_PROVIDER === 'gatographql'
? {
PAGE_FIELDS: GATOGRAPHQL_PAGE_FIELDS,
QUERY_ALL_PAGES_INDEX: GATOGRAPHQL_QUERY_ALL_PAGES_INDEX,
Expand Down
6 changes: 2 additions & 4 deletions src/data/posts.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { WORDPRESS_GRAPHQL_PROVIDER_WPGRAPHQL, WORDPRESS_GRAPHQL_PROVIDER_GATOGRAPHQL } from './providers/providers';

import {
POST_FIELDS as WPGRAPHQL_POST_FIELDS,
QUERY_ALL_POSTS_INDEX as WPGRAPHQL_QUERY_ALL_POSTS_INDEX,
Expand Down Expand Up @@ -35,7 +33,7 @@ import {
const { WORDPRESS_GRAPHQL_PROVIDER } = process.env;

module.exports = {
...(WORDPRESS_GRAPHQL_PROVIDER === WORDPRESS_GRAPHQL_PROVIDER_WPGRAPHQL
...(WORDPRESS_GRAPHQL_PROVIDER === 'wpgraphql'
? {
POST_FIELDS: WPGRAPHQL_POST_FIELDS,
QUERY_ALL_POSTS_INDEX: WPGRAPHQL_QUERY_ALL_POSTS_INDEX,
Expand All @@ -52,7 +50,7 @@ module.exports = {
QUERY_POST_PER_PAGE: WPGRAPHQL_QUERY_POST_PER_PAGE,
}
: {}),
...(WORDPRESS_GRAPHQL_PROVIDER === WORDPRESS_GRAPHQL_PROVIDER_GATOGRAPHQL
...(WORDPRESS_GRAPHQL_PROVIDER === 'gatographql'
? {
POST_FIELDS: GATOGRAPHQL_POST_FIELDS,
QUERY_ALL_POSTS_INDEX: GATOGRAPHQL_QUERY_ALL_POSTS_INDEX,
Expand Down
2 changes: 0 additions & 2 deletions src/data/providers/providers.js

This file was deleted.

6 changes: 2 additions & 4 deletions src/data/site.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { WORDPRESS_GRAPHQL_PROVIDER_WPGRAPHQL, WORDPRESS_GRAPHQL_PROVIDER_GATOGRAPHQL } from './providers/providers';

import {
QUERY_SITE_DATA as WPGRAPHQL_QUERY_SITE_DATA,
QUERY_SEO_DATA as WPGRAPHQL_QUERY_SEO_DATA,
Expand All @@ -13,13 +11,13 @@ import {
const { WORDPRESS_GRAPHQL_PROVIDER } = process.env;

module.exports = {
...(WORDPRESS_GRAPHQL_PROVIDER === WORDPRESS_GRAPHQL_PROVIDER_WPGRAPHQL
...(WORDPRESS_GRAPHQL_PROVIDER === 'wpgraphql'
? {
QUERY_SITE_DATA: WPGRAPHQL_QUERY_SITE_DATA,
QUERY_SEO_DATA: WPGRAPHQL_QUERY_SEO_DATA,
}
: {}),
...(WORDPRESS_GRAPHQL_PROVIDER === WORDPRESS_GRAPHQL_PROVIDER_GATOGRAPHQL
...(WORDPRESS_GRAPHQL_PROVIDER === 'gatographql'
? {
QUERY_SITE_DATA: GATOGRAPHQL_QUERY_SITE_DATA,
QUERY_SEO_DATA: GATOGRAPHQL_QUERY_SEO_DATA,
Expand Down
6 changes: 2 additions & 4 deletions src/data/users.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { WORDPRESS_GRAPHQL_PROVIDER_WPGRAPHQL, WORDPRESS_GRAPHQL_PROVIDER_GATOGRAPHQL } from './providers/providers';

import {
QUERY_ALL_USERS as WPGRAPHQL_QUERY_ALL_USERS,
QUERY_ALL_USERS_SEO as WPGRAPHQL_QUERY_ALL_USERS_SEO,
Expand All @@ -13,13 +11,13 @@ import {
const { WORDPRESS_GRAPHQL_PROVIDER } = process.env;

module.exports = {
...(WORDPRESS_GRAPHQL_PROVIDER === WORDPRESS_GRAPHQL_PROVIDER_WPGRAPHQL
...(WORDPRESS_GRAPHQL_PROVIDER === 'wpgraphql'
? {
QUERY_ALL_USERS: WPGRAPHQL_QUERY_ALL_USERS,
QUERY_ALL_USERS_SEO: WPGRAPHQL_QUERY_ALL_USERS_SEO,
}
: {}),
...(WORDPRESS_GRAPHQL_PROVIDER === WORDPRESS_GRAPHQL_PROVIDER_GATOGRAPHQL
...(WORDPRESS_GRAPHQL_PROVIDER === 'gatographql'
? {
QUERY_ALL_USERS: GATOGRAPHQL_QUERY_ALL_USERS,
QUERY_ALL_USERS_SEO: GATOGRAPHQL_QUERY_ALL_USERS_SEO,
Expand Down
6 changes: 2 additions & 4 deletions src/lib/provider.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { WORDPRESS_GRAPHQL_PROVIDER_WPGRAPHQL, WORDPRESS_GRAPHQL_PROVIDER_GATOGRAPHQL } from './providers/providers';

/**
* getProvider
*/

export async function getProvider() {
const providers = [WORDPRESS_GRAPHQL_PROVIDER_WPGRAPHQL, WORDPRESS_GRAPHQL_PROVIDER_GATOGRAPHQL];
const defaultProvider = WORDPRESS_GRAPHQL_PROVIDER_WPGRAPHQL;
const providers = ['wpgraphql', 'gatographql'];
const defaultProvider = 'wpgraphql';
const selectedProvider = (process.env.WORDPRESS_GRAPHQL_PROVIDER || '').toLowerCase();
if (!selectedProvider || !providers.includes(selectedProvider)) return defaultProvider;

Expand Down

0 comments on commit 514e8bf

Please sign in to comment.