aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.42k stars 2.12k forks source link

Allow updating graphql endpoint dynamically #8737

Open VivekNeel opened 3 years ago

VivekNeel commented 3 years ago

Is this related to a new or existing framework?

React, React Native

Is this related to a new or existing API?

GraphQL API

Is this related to another service?

No response

Describe the feature you'd like to request

We are using both graphql & graphcdn endpoints and we have use-case where we want few queries to go via graphcdn and rest of them via normal graphql endpoint.

It would be great if we can update the end-point dynamically before the query runs. This is the configuration we have right now :

import API from '@aws-amplify/api';

const AmplifyWebConfig = {
  Auth: {
    userPoolId: awsExports.UserPoolId,
    userPoolWebClientId: awsExports.UserPoolClientIdWeb,
    identityPoolId: awsExports.IdentityPoolId,
    region: awsExports.Region,
    authenticationFlowType: 'USER_PASSWORD_AUTH',
  },
  aws_appsync_graphqlEndpoint: awsExports['API-Endpoint'],
  aws_appsync_region: awsExports.Region,
  aws_appsync_authenticationType: 'AWS_IAM',
  graphql_headers: graphqlHeader,
};
API.configure(AmplifyWebConfig);

I'm trying to update aws_appsync_graphqlEndpoint on the fly. Currently am re-configuring aws with the graphcdn endpoint for the queries i want to get cached which does not sounds like a feasible solution.

Describe the solution you'd like

Give ability to update aws_appsync_graphqlEndpoint on the fly. Something like API.updateEndPoint()

Describe alternatives you've considered

Currently am re-configuring aws with the graphcdn endpoint for the queries i want to get cached which does not sounds like a feasible solution.

Additional context

No response

Is this something that you'd be interested in working on?

lon9man commented 2 years ago

@VivekNeel am i correctly understand that amplify can't work with multiple GraphQL-endpoints (including non-AWS)? i see method endpoint in amplify API, but don't see examples used it. maybe it used for non-GraphQL APIs image

questions:

  1. maybe you have some deeper info about the case?
  2. did you resolve own problem?