@auth not working for custom Query and resolvers
See original GitHub issueI have implemented multi asuthentication systems into my amploify project, with Cognito pools are the default and IAM as the secondary.
All works fine for the authentication on amplify generated queries and mutation, however my custom queries always return the following when called:
GraphQL Error: message: “Request failed with status code 401”
My queries:
type Query {
searchElasticEvents(input: SearchEventsInput): EventConnection @aws_iam @aws_cognito_user_pools
searchElasticPlaces(input: SearchPlacesInput): EntityConnection
}
I have tried with adding the ’ @aws_iam @aws_cognito_user_pools’ directives, and without and both error.
I can’t add the auth directive as that requires the @model directive to be present.
The custom resolvers contain no authentication checks as I wish them to be public, so why is it giving me an authentication error:
Front end call:
` const { data } = await this.amplify.api().graphql({
query: searchElasticPlaces,
variables: { input },
authMode: 'AWS_IAM'
});`
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:38 (6 by maintainers)
Top Results From Across the Web
Writing query resolvers | Full-Stack Quickstart - Apollo GraphQL
Whenever a client queries for a particular field, the resolver for that field ... Use this to share per-operation state, such as authentication...
Read more >Custom Resolvers - Neo4j GraphQL Library
Custom Resolvers. A common case for using the OGM will be within custom resolvers inside a Neo4j GraphQL instance (very meta!), due to...
Read more >Troubleshooting and Common Mistakes - AWS AppSync
If you execute a GraphQL operation, such as a query, and get a null response, this may be because you don't have a...
Read more >Resolvers Composition Transform – GraphQL Mesh
transforms: - resolversComposition: mode: bare | wrap compositions: - resolver: 'Query.me' composer: is-auth#isAuth - resolver: 'Mutation.
Read more >Resolvers | Nestjs-query - Blog
otherwise relations will not work. todo-item.resolver.ts. import { QueryService, InjectQueryService } from '@nestjs-query/core';import { CRUDResolver } from ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Related to #2711 and #3590 contains support for this functionality for custom queries backed by functions or custom resolvers.
Given the following schema:
This will be the output schema the CLI will generate:
It will add the
@aws_iam
directive to the query with the@auth
rule and also generate the appropriate entry inAuthRolePolicynn
orUnauthRolePolicynn
:Notice that since
EventConnection
has no@model
directive - for now - it requires the@aws_iam
directive to be in place and also the policy entry for that type.+1
Same problem with a mutation method, I have tried @auth @aws_iam @aws_api_key, both without success. It works just with group User with Cognito.