Skip to content
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

Request based graphQL api endpoint change in Amplify #459

Open
1 of 2 tasks
mattiLeBlanc opened this issue Aug 8, 2024 · 1 comment
Open
1 of 2 tasks

Request based graphQL api endpoint change in Amplify #459

mattiLeBlanc opened this issue Aug 8, 2024 · 1 comment
Assignees
Labels

Comments

@mattiLeBlanc
Copy link

Is this related to a new or existing framework?

Angular

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

I would like to be able to call a different API endpoint from my Angular app if I need then the one that is configured in Amplify.configure.

I currently add a custom header:

Amplify.configure(awsConfig.adminApp, {
  API: {
   GraphQL: {
     headers: async () => {
       const currentSession = await fetchAuthSession();
       if (currentSession.tokens) {
         const idToken = currentSession.tokens.idToken?.toString();
         return { Authorization: idToken };
       } else {
         return undefined
       }
     }
   }
  }
});

and I am using this switch in my api graphql function:


  graphql<V>({ statement: query, variables, type, iam = false, familyApi = false }: queryInput) {
    if (familyApi) {
      Amplify.configure(awsConfig.familyApp);
    } else {
      Amplify.configure(awsConfig.adminApp);
    }
....

to swap the API config.

Describe the solution you'd like

What I am currently using, works, but it may not be the best way because I may be resetting the API configuration every time I do this.
A better option would be to have an option to override the graphQl endpoint in the (this.client.graphql(payload) function.
Because I am not sure I am losing my ID Token custom header if I run the configure again in my graphql function (I could add it).

Describe alternatives you've considered

no alternatives

Additional context

No response

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

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change
@cwomack cwomack added the GraphQL label Aug 8, 2024
@chrisbonifacio chrisbonifacio added feature-request New feature or request and removed pending-triage labels Aug 8, 2024
@chrisbonifacio chrisbonifacio self-assigned this Aug 8, 2024
@chrisbonifacio
Copy link
Member

Hi @mattiLeBlanc thanks for raising this issue. I've marked it as a feature request for the team to consider.

@stocaaro stocaaro transferred this issue from aws-amplify/amplify-js Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants