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

72246 implement graphql client #29

Merged
merged 6 commits into from
Sep 22, 2022
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
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
NEXT_PUBLIC_BUILD_DATE = 12345
NEXT_CMS_URL = "test.com"
AEM_GRAPHQL_ENDPOINT = "test.com"
LOGGING_LEVEL = " info or debug"
12 changes: 4 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ FROM base AS build
# Build envs
ARG BUILD_DATE
ENV BUILD_DATE=$BUILD_DATE
ARG ENV_EXAMPLE
ENV ENV_EXAMPLE=$ENV_EXAMPLE
ARG NEXT_PUBLIC_ENV_EXAMPLE
ENV NEXT_PUBLIC_ENV_EXAMPLE=$NEXT_PUBLIC_ENV_EXAMPLE
ARG AEM_GRAPHQL_ENDPOINT
ENV AEM_GRAPHQL_ENDPOINT=$AEM_GRAPHQL_ENDPOINT
s-laugh marked this conversation as resolved.
Show resolved Hide resolved

ENV NODE_ENV=production
WORKDIR /build
Expand All @@ -30,9 +28,7 @@ COPY --from=build /build/tracing.js ./
RUN VERSION_NEXT=`node -p -e "require('./package.json').dependencies.next"`&& npm install --no-package-lock --no-save next@"$VERSION_NEXT"

# Runtime envs -- will default to build args if no env values are specified at docker run
ARG ENV_EXAMPLE
ENV ENV_EXAMPLE=$ENV_EXAMPLE
ARG NEXT_PUBLIC_ENV_EXAMPLE
ENV NEXT_PUBLIC_ENV_EXAMPLE=$NEXT_PUBLIC_ENV_EXAMPLE
ARG AEM_GRAPHQL_ENDPOINT
ENV AEM_GRAPHQL_ENDPOINT=$AEM_GRAPHQL_ENDPOINT

CMD npm run start
23 changes: 23 additions & 0 deletions graphql/client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ApolloClient, InMemoryCache, HttpLink } from '@apollo/client'

const link = new HttpLink({
uri: process.env.AEM_GRAPHQL_ENDPOINT,
headers: {
'User-Agent': 'secure-client-hub/0.0.1',
},
})

const client = new ApolloClient({
link: link,
cache: new InMemoryCache(),
})

export default async function (AEMQuery) {
return client
.query({
query: AEMQuery,
})
.catch((error) => {
console.log(error)
s-laugh marked this conversation as resolved.
Show resolved Hide resolved
})
}
Loading