Skip to content

Commit

Permalink
Remove graphiql in prod
Browse files Browse the repository at this point in the history
  • Loading branch information
shahanneda committed Sep 1, 2024
1 parent be5353f commit 2a4986c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion backend/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from flask_cors import CORS
from .graphql.view import GraphQLView
from logging.config import dictConfig
from graphene.validation import depth_limit_validator

from .config import app_config
from .graphql import schema as graphql_schema
Expand Down Expand Up @@ -96,7 +97,12 @@ def create_app(config_name):
view_func=GraphQLView.as_view(
"graphql",
schema=graphql_schema,
graphiql=True,
graphiql=False if config_name == "production" else True,
validation_rules=(
# We can't turn this off since for some reason the Apollo Client needs this to make any queries
# DisableIntrospection,
depth_limit_validator(max_depth=20),
),
),
)

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApolloClient, ApolloProvider, InMemoryCache } from "@apollo/client";
import { ApolloClient, ApolloLink, ApolloProvider, InMemoryCache } from "@apollo/client";
import { setContext } from "@apollo/client/link/context";
import { removeTypenameFromVariables } from "@apollo/client/link/remove-typename";
import { ChakraProvider } from "@chakra-ui/react";
Expand Down Expand Up @@ -89,7 +89,7 @@ const authLink = setContext(async (_, { headers }) => {
const removeTypenameLink = removeTypenameFromVariables();

const apolloClient = new ApolloClient({
link: removeTypenameLink.concat(authLink).concat(link),
link: ApolloLink.from([removeTypenameLink, authLink, link]),
cache: new InMemoryCache({
typePolicies: {
MealRequestResponse: {
Expand Down

0 comments on commit 2a4986c

Please sign in to comment.