yarn install
: pacakge installyarn build
: buildyarn gql-gen --watch
: regenerategraphql.tsx
and watch the changes of graphql typeyarn start
: run in local
REACT_APP_
: custom variables need this prefix- use
process.env.REACT_APP_{env_var_name}
๐งโโ๏ธdon't install dotenv package
e.g. .env
PORT=7000 // client port
REACT_APP_SERVER_BASE_URL=http://localhost:3000 // server url
REACT_APP_
: custom variables need this prefix- use
process.env.REACT_APP_{env_var_name}
๐งโโ๏ธdon't install dotenv package
e.g. .env
PORT=7000 // client port
REACT_APP_SERVER_BASE_URL=http://localhost:3000 // server url
e.g. in .tsx
- graphql document ์์ฑ ์์
gql`
query HelloWorld {
helloWorld
}
`
- import
use{QueryName}Query
fromsrc/generated/graphql.tsx
- You can use data, loading, error, etc from response(๐)
import { useHelloWorldQuery } from 'src/generated/graphql.tsx'
const App = () => {
const { data, loading, error } = useHelloWorldQuery()
if (loading) {
return (
<div>
<p>loading...</p>
</div>
)
}
if (error) return null
return (
<div className="App">
{data?.helloWorld}
<Pages />
</div>
)
}
export default App