Skip to content

Commit e111ac1

Browse files
committed
feat(data): add multi-endpoint instructions
1 parent 102741e commit e111ac1

File tree

1 file changed

+39
-0
lines changed
  • src/pages/[platform]/build-a-backend/data/connect-to-API

1 file changed

+39
-0
lines changed

src/pages/[platform]/build-a-backend/data/connect-to-API/index.mdx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,3 +694,42 @@ await Amplify.addPlugins([
694694
```
695695

696696
</InlineFilter>
697+
698+
<InlineFilter filters={["javascript", "angular", "react-native", "react", "nextjs", "vue"]}>
699+
700+
## Use an additional Data endpoint
701+
702+
If you have an additional Data endpoint that you're managing with a different Amplify project or through other means, this section will show you how to utilize that endpoint in your frontend code.
703+
704+
This is done by specifying the `endpoint` parameter on the `generateClient` function.
705+
706+
```ts
707+
import { generateClient } from 'aws-amplify/data';
708+
709+
const client = generateClient({
710+
endpoint: 'https://my-other-endpoint.com/graphql',
711+
});
712+
```
713+
714+
If this Data endpoint shares its authorization configuration (for example, both endpoints share the same user pool and/or identity pool as the one in your `amplify_outputs.json` file), you can specify the `authMode` parameter on `generateClient`.
715+
716+
```ts
717+
const client = generateClient({
718+
endpoint: 'https://my-other-endpoint.com/graphql',
719+
authMode: 'userPool',
720+
});
721+
```
722+
723+
If the endpoint uses API Key authorization, you can pass in the `apiKey` parameter on `generateClient`.
724+
725+
```ts
726+
const client = generateClient({
727+
endpoint: 'https://my-other-endpoint.com/graphql',
728+
authMode: 'apiKey',
729+
apiKey: 'my-api-key',
730+
});
731+
```
732+
733+
If the endpoint uses a different authorization configuration, you can manually pass in the authorization header using the instructions in the [Set custom request headers](#set-custom-request-headers) section.
734+
735+
</InlineFilter>

0 commit comments

Comments
 (0)