Skip to content

Commit

Permalink
Changes to fix examples
Browse files Browse the repository at this point in the history
- Used commonjs module resolution in tsconfig.json
- Changed 'AppCountriesQuery' to 'appCountriesQuery' in app.tsx
to satisfy the relay compiler
- Changed 'type' in package.json to 'commonjs' to satisfy relay
  • Loading branch information
doloboyz committed Jun 25, 2024
1 parent 2fc3603 commit ccbdee9
Show file tree
Hide file tree
Showing 15 changed files with 211 additions and 217 deletions.
2 changes: 1 addition & 1 deletion examples/01_minimal/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jotai-relay-example",
"version": "0.1.0",
"type": "module",
"type": "commonjs",
"private": true,
"dependencies": {
"babel-plugin-relay": "latest",
Expand Down
9 changes: 6 additions & 3 deletions examples/01_minimal/relay.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
export default {
// eslint-disable-next-line no-undef
module.exports = {
language: 'typescript',
src: '../src',
schema: './data/schema.graphql',
// eslint-disable-next-line no-undef
src: `${__dirname}/src`,
// eslint-disable-next-line no-undef
schema: `${__dirname}/data/schema.graphql`,
exclude: ['**/node_modules/**', '**/__mocks__/**', '**/__generated__/**'],
};
108 changes: 54 additions & 54 deletions examples/01_minimal/src/__generated__/AppCountriesQuery.graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions examples/01_minimal/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
graphql,
} from 'relay-runtime';

import type { AppCountriesQuery } from './__generated__/AppCountriesQuery.graphql';
import type { appCountriesQuery } from './__generated__/AppCountriesQuery.graphql';

const myEnvironment = new Environment({
network: Network.create(async (params, variables) => {
Expand All @@ -29,9 +29,9 @@ const myEnvironment = new Environment({
store: new Store(new RecordSource()),
});

const countriesAtom = atomWithQuery<AppCountriesQuery>(
const countriesAtom = atomWithQuery<appCountriesQuery>(
graphql`
query AppCountriesQuery {
query appCountriesQuery {
countries {
name
}
Expand All @@ -42,10 +42,11 @@ const countriesAtom = atomWithQuery<AppCountriesQuery>(

const Main = () => {
const [data] = useAtom(countriesAtom);

return (
<ul>
{data.countries.map(({ name }) => (
<li key={name}>{name}</li>
{data.countries.map((country: { name: string }) => (
<li key={country.name}>{country.name}</li>
))}
</ul>
);
Expand Down
3 changes: 1 addition & 2 deletions examples/01_minimal/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"strict": true,
"target": "es2018",
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"module": "CommonJS",
"skipLibCheck": true,
"allowJs": true,
"noUncheckedIndexedAccess": true,
Expand Down
2 changes: 1 addition & 1 deletion examples/02_typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jotai-relay-example",
"version": "0.1.0",
"type": "module",
"type": "commonjs",
"private": true,
"dependencies": {
"babel-plugin-relay": "latest",
Expand Down
108 changes: 54 additions & 54 deletions examples/02_typescript/src/__generated__/AppCountriesQuery.graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions examples/02_typescript/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Environment, Network, RecordSource, Store } from 'relay-runtime';
// @ts-ignore
import graphql from 'babel-plugin-relay/macro';

import type { AppCountriesQuery } from './__generated__/AppCountriesQuery.graphql';
import type { appCountriesQuery } from './__generated__/AppCountriesQuery.graphql';

const myEnvironment = new Environment({
network: Network.create(async (params, variables) => {
Expand All @@ -26,9 +26,9 @@ const myEnvironment = new Environment({
store: new Store(new RecordSource()),
});

const countriesAtom = atomWithQuery<AppCountriesQuery>(
const countriesAtom = atomWithQuery<appCountriesQuery>(
graphql`
query AppCountriesQuery {
query appCountriesQuery {
countries {
name
}
Expand Down
3 changes: 1 addition & 2 deletions examples/02_typescript/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"strict": true,
"target": "es2018",
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"module": "CommonJS",
"skipLibCheck": true,
"allowJs": true,
"noUncheckedIndexedAccess": true,
Expand Down
2 changes: 1 addition & 1 deletion examples/03_errorhandling/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jotai-relay-example",
"version": "0.1.0",
"type": "module",
"type": "commonjs",
"private": true,
"dependencies": {
"babel-plugin-relay": "latest",
Expand Down
Loading

0 comments on commit ccbdee9

Please sign in to comment.