-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: SB-732, SB-753 Init Apollo migration
- Loading branch information
Showing
23 changed files
with
3,841 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
overwrite: true | ||
ignoreNoDocuments: true | ||
schema: | ||
- ./graphql/schema/schema.graphql: | ||
loader: ./graphql/schema/loader.js | ||
generates: | ||
src/shared/services/graphqlApi/__generated/gql/: | ||
documents: ['src/**/*.ts', 'src/**/*.tsx', '!src/shared/services/**/__generated/*', '!src/**/__generated__/*.graphql.ts'] | ||
pluckConfig: | ||
modules: | ||
- name: babel-plugin-relay/macro | ||
identifier: graphql | ||
preset: 'client' | ||
plugins: [] | ||
presetConfig: | ||
gqlTagName: 'gql' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ReactNode } from 'react'; | ||
import { ApolloProvider as Provider } from '@apollo/client'; | ||
|
||
import { client } from '../../shared/services/graphqlApi/apolloClient'; | ||
|
||
export const ApolloProvider = ({ children }: { children: ReactNode }) => ( | ||
<Provider client={client}>{children}</Provider> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 34 additions & 22 deletions
56
...ages/webapp/src/routes/crudDemoItem/crudDemoItemDetails/crudDemoItemDetails.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,48 @@ | ||
import { Suspense, useEffect } from 'react'; | ||
import graphql from 'babel-plugin-relay/macro'; | ||
import { useQueryLoader } from 'react-relay'; | ||
import { useQuery } from '@apollo/client'; | ||
import { useParams } from 'react-router'; | ||
import { crudDemoItemDetailsQuery } from './__generated__/crudDemoItemDetailsQuery.graphql'; | ||
import { CrudDemoItemDetailsContent } from './crudDemoItemDetailsContent.component'; | ||
import { FormattedMessage } from 'react-intl'; | ||
import { gql } from '../../../shared/services/graphqlApi/__generated/gql'; | ||
import { useGenerateLocalePath } from '../../../shared/hooks/localePaths'; | ||
import { BackButton } from '../../../shared/components/backButton'; | ||
import { RoutesConfig } from '../../../app/config/routes'; | ||
import { Container, Header } from './crudDemoItemDetails.styles'; | ||
|
||
export const CRUD_DEMO_ITEM_DETAILS_QUERY = gql(/* GraphQL */ ` | ||
query crudDemoItemDetailsQuery($id: ID!) { | ||
crudDemoItem(id: $id) { | ||
id | ||
name | ||
} | ||
} | ||
`); | ||
|
||
export const CrudDemoItemDetails = () => { | ||
type Params = { | ||
id: string; | ||
}; | ||
const generateLocalePath = useGenerateLocalePath(); | ||
const { id } = useParams<keyof Params>() as Params; | ||
|
||
const [queryRef, loadQuery] = useQueryLoader<crudDemoItemDetailsQuery>(graphql` | ||
query crudDemoItemDetailsQuery($id: ID!) { | ||
crudDemoItem(id: $id) { | ||
id | ||
name | ||
} | ||
} | ||
`); | ||
|
||
useEffect(() => { | ||
loadQuery({ id }); | ||
}, [loadQuery, id]); | ||
const { loading, data } = useQuery(CRUD_DEMO_ITEM_DETAILS_QUERY, { | ||
variables: { | ||
id, | ||
}, | ||
}); | ||
|
||
if (!queryRef) { | ||
return null; | ||
if (loading) { | ||
return ( | ||
<span> | ||
<FormattedMessage defaultMessage="Loading ..." id="Loading message" /> | ||
</span> | ||
); | ||
} | ||
|
||
const itemData = data?.crudDemoItem; | ||
|
||
return ( | ||
<Suspense fallback={<span>Loading ...</span>}> | ||
<CrudDemoItemDetailsContent queryRef={queryRef} /> | ||
</Suspense> | ||
<Container> | ||
<BackButton to={generateLocalePath(RoutesConfig.crudDemoItem.list)} /> | ||
<Header>{itemData?.name}</Header> | ||
</Container> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 0 additions & 24 deletions
24
...bapp/src/routes/crudDemoItem/crudDemoItemDetails/crudDemoItemDetailsContent.component.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.