Skip to content

Commit

Permalink
Add graphql-let for typesafe GraphQL queries.
Browse files Browse the repository at this point in the history
  • Loading branch information
Konsta Purtsi committed Feb 8, 2022
1 parent 4b13485 commit b851ffb
Show file tree
Hide file tree
Showing 12 changed files with 17,122 additions and 4,173 deletions.
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": ["next/babel"],
"plugins": ["graphql-let/babel"]
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ yarn-error.log*
# vercel
.vercel
.env.local
*.graphql.d.ts
*.graphqls.d.ts
/.cache
11 changes: 11 additions & 0 deletions .graphql-let.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
schema:
- https://graphql.contentful.com/content/v1/spaces/${CONTENTFUL_SPACE_ID}:
headers:
Authorization: "Bearer ${CONTENTFUL_ACCESS_TOKEN}"
documents:
- '**/*.graphql'
- '**/*.tsx'
plugins:
- typescript-operations
- typescript-react-apollo
cacheDir: .cache
4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
node_modules/
.next/
out/
package-lock.json
package-lock.json
.cache/
**/*.graphql.d.ts
4 changes: 2 additions & 2 deletions components/hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { LinkButton } from './button';

interface HeroProps {
image: {
url: string;
url?: string;
};
title: string;
subtext: string;
Expand All @@ -20,7 +20,7 @@ function Hero({ image, title, subtext, buttonText, buttonLink }: HeroProps) {
<div className="relative flex flex-col w-full h-128 xl:h-192">
{/* Hero image */}
<Image
src={url}
src={url} // TODO: fallback for missing urls.
loader={imageLoader}
layout="fill"
objectFit="cover"
Expand Down
15 changes: 15 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,19 @@ module.exports = {
images: {
domains: ['images.ctfassets.net'],
},
webpack(config, options) {
config.module.rules.push({
test: /\.(tsx|graphql)$/,
exclude: /node_modules/,
use: [options.defaultLoaders.babel, { loader: 'graphql-let/loader' }],
});

config.module.rules.push({
test: /\.ya?ml$/,
type: 'json',
use: 'yaml-loader',
});

return config;
},
};
Loading

0 comments on commit b851ffb

Please sign in to comment.