-
Notifications
You must be signed in to change notification settings - Fork 1k
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
GraphQL Codegen for generating gql types #2485
Changes from all commits
7e55b4f
8f33a50
b3d69d6
cc0bebe
07647f0
4b44d71
f6ca2a7
fd13069
597c92d
3fef77c
cb91955
34e027f
52b5835
9d5efe5
22310cb
aa493e8
36d669a
9fe1ef2
1a67d1e
af6c749
2a14dd2
b847c5d
c65c9e0
e02c4e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,7 +169,7 @@ export const Success = ({ userProfile }) => { | |
|
||
exports[`creates a cell mock with a camelCase word name 1`] = ` | ||
"// Define your own mock data here: | ||
export const standard = (/* vars, { ctx, req } */) => ({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dunno why the snapshots do this weird thing. Its not actually doing this when we actually generate 🤷♂️ |
||
export const standard = () => /* vars, { ctx, req } */ ({ | ||
userProfile: { | ||
id: 42, | ||
}, | ||
|
@@ -179,7 +179,7 @@ export const standard = (/* vars, { ctx, req } */) => ({ | |
|
||
exports[`creates a cell mock with a kebabCase word name 1`] = ` | ||
"// Define your own mock data here: | ||
export const standard = (/* vars, { ctx, req } */) => ({ | ||
export const standard = () => /* vars, { ctx, req } */ ({ | ||
userProfile: { | ||
id: 42, | ||
}, | ||
|
@@ -189,7 +189,7 @@ export const standard = (/* vars, { ctx, req } */) => ({ | |
|
||
exports[`creates a cell mock with a multi word name 1`] = ` | ||
"// Define your own mock data here: | ||
export const standard = (/* vars, { ctx, req } */) => ({ | ||
export const standard = () => /* vars, { ctx, req } */ ({ | ||
userProfile: { | ||
id: 42, | ||
}, | ||
|
@@ -199,7 +199,7 @@ export const standard = (/* vars, { ctx, req } */) => ({ | |
|
||
exports[`creates a cell mock with a single word name 1`] = ` | ||
"// Define your own mock data here: | ||
export const standard = (/* vars, { ctx, req } */) => ({ | ||
export const standard = () => /* vars, { ctx, req } */ ({ | ||
user: { | ||
id: 42, | ||
}, | ||
|
@@ -209,7 +209,7 @@ export const standard = (/* vars, { ctx, req } */) => ({ | |
|
||
exports[`creates a cell mock with a snakeCase word name 1`] = ` | ||
"// Define your own mock data here: | ||
export const standard = (/* vars, { ctx, req } */) => ({ | ||
export const standard = () => /* vars, { ctx, req } */ ({ | ||
userProfile: { | ||
id: 42, | ||
}, | ||
|
@@ -338,7 +338,7 @@ export default { title: 'Cells/UserProfileCell' } | |
`; | ||
|
||
exports[`creates a cell test with a camelCase word name 1`] = ` | ||
"import { render, screen } from '@redwoodjs/testing' | ||
"import { render } from '@redwoodjs/testing' | ||
import { Loading, Empty, Failure, Success } from './UserProfileCell' | ||
import { standard } from './UserProfileCell.mock' | ||
|
||
|
@@ -364,7 +364,8 @@ describe('UserProfileCell', () => { | |
// When you're ready to test the actual output of your component render | ||
// you could test that, for example, certain text is present: | ||
// | ||
// expect(screen.getByText('Hello, world')).toBeInTheDocument() | ||
// 1. import { screen } from '@redwoodjs/testing' | ||
// 2. Add test: expect(screen.getByText('Hello, world')).toBeInTheDocument() | ||
|
||
it('renders Success successfully', async () => { | ||
expect(() => { | ||
|
@@ -376,7 +377,7 @@ describe('UserProfileCell', () => { | |
`; | ||
|
||
exports[`creates a cell test with a kebabCase word name 1`] = ` | ||
"import { render, screen } from '@redwoodjs/testing' | ||
"import { render } from '@redwoodjs/testing' | ||
import { Loading, Empty, Failure, Success } from './UserProfileCell' | ||
import { standard } from './UserProfileCell.mock' | ||
|
||
|
@@ -402,7 +403,8 @@ describe('UserProfileCell', () => { | |
// When you're ready to test the actual output of your component render | ||
// you could test that, for example, certain text is present: | ||
// | ||
// expect(screen.getByText('Hello, world')).toBeInTheDocument() | ||
// 1. import { screen } from '@redwoodjs/testing' | ||
// 2. Add test: expect(screen.getByText('Hello, world')).toBeInTheDocument() | ||
|
||
it('renders Success successfully', async () => { | ||
expect(() => { | ||
|
@@ -414,7 +416,7 @@ describe('UserProfileCell', () => { | |
`; | ||
|
||
exports[`creates a cell test with a multi word name 1`] = ` | ||
"import { render, screen } from '@redwoodjs/testing' | ||
"import { render } from '@redwoodjs/testing' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another one of the weird snapshot things. Something to do with tsToJs maybe |
||
import { Loading, Empty, Failure, Success } from './UserProfileCell' | ||
import { standard } from './UserProfileCell.mock' | ||
|
||
|
@@ -440,7 +442,8 @@ describe('UserProfileCell', () => { | |
// When you're ready to test the actual output of your component render | ||
// you could test that, for example, certain text is present: | ||
// | ||
// expect(screen.getByText('Hello, world')).toBeInTheDocument() | ||
// 1. import { screen } from '@redwoodjs/testing' | ||
// 2. Add test: expect(screen.getByText('Hello, world')).toBeInTheDocument() | ||
|
||
it('renders Success successfully', async () => { | ||
expect(() => { | ||
|
@@ -452,7 +455,7 @@ describe('UserProfileCell', () => { | |
`; | ||
|
||
exports[`creates a cell test with a single word name 1`] = ` | ||
"import { render, screen } from '@redwoodjs/testing' | ||
"import { render } from '@redwoodjs/testing' | ||
import { Loading, Empty, Failure, Success } from './UserCell' | ||
import { standard } from './UserCell.mock' | ||
|
||
|
@@ -478,7 +481,8 @@ describe('UserCell', () => { | |
// When you're ready to test the actual output of your component render | ||
// you could test that, for example, certain text is present: | ||
// | ||
// expect(screen.getByText('Hello, world')).toBeInTheDocument() | ||
// 1. import { screen } from '@redwoodjs/testing' | ||
// 2. Add test: expect(screen.getByText('Hello, world')).toBeInTheDocument() | ||
|
||
it('renders Success successfully', async () => { | ||
expect(() => { | ||
|
@@ -490,7 +494,7 @@ describe('UserCell', () => { | |
`; | ||
|
||
exports[`creates a cell test with a snakeCase word name 1`] = ` | ||
"import { render, screen } from '@redwoodjs/testing' | ||
"import { render } from '@redwoodjs/testing' | ||
import { Loading, Empty, Failure, Success } from './UserProfileCell' | ||
import { standard } from './UserProfileCell.mock' | ||
|
||
|
@@ -516,7 +520,8 @@ describe('UserProfileCell', () => { | |
// When you're ready to test the actual output of your component render | ||
// you could test that, for example, certain text is present: | ||
// | ||
// expect(screen.getByText('Hello, world')).toBeInTheDocument() | ||
// 1. import { screen } from '@redwoodjs/testing' | ||
// 2. Add test: expect(screen.getByText('Hello, world')).toBeInTheDocument() | ||
|
||
it('renders Success successfully', async () => { | ||
expect(() => { | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { ${operationName} } from 'types/gql-types' | ||
import type { CellSuccessProps, CellFailureProps } from '@redwoodjs/web' | ||
|
||
export const QUERY = gql` | ||
query ${operationName}($id: ${idType}!) { | ||
${camelName}: ${camelName}(id: $id) { | ||
id | ||
} | ||
} | ||
` | ||
|
||
export const Loading = () => <div>Loading...</div> | ||
|
||
export const Empty = () => <div>Empty</div> | ||
|
||
export const Failure = ({ error }: CellFailureProps) => ( | ||
<div style={{ color: 'red' }}>Error: {error.message}</div> | ||
) | ||
|
||
export const Success = ({ ${camelName} }: CellSuccessProps<${operationName}>) => { | ||
return <div>{JSON.stringify(${camelName})}</div> | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { ${operationName} } from 'types/gql-types' | ||
import type { CellSuccessProps, CellFailureProps } from '@redwoodjs/web' | ||
|
||
|
||
export const QUERY = gql` | ||
query ${operationName} { | ||
${camelName} { | ||
id | ||
} | ||
} | ||
` | ||
|
||
export const Loading = () => <div>Loading...</div> | ||
|
||
export const Empty = () => <div>Empty</div> | ||
|
||
export const Failure = ({ error }: CellFailureProps) => ( | ||
<div style={{ color: 'red' }}>Error: {error.message}</div> | ||
) | ||
|
||
export const Success = ({ ${camelName} }: CellSuccessProps<${operationName}>) => { | ||
return ( | ||
<ul> | ||
{${camelName}.map((item) => { | ||
return <li key={item.id}>{JSON.stringify(item)}</li> | ||
})} | ||
</ul> | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will also allow us to use tailwind's JIT without more hassle