Skip to content

How can I attach a resolver to a field in Appsync with SAM? #3685

Open
@peragethemte

Description

I have a GraphQL schema with a query. The query uses a lambda resolver that connects to a REST API and fetches the data. I want to have the field TimeSchedules on the type AccessGroup to use a different resolver and I've managed to get this to work in the console but it doesn't seem to be possible with SAM.

Parts of schema:

type Query {
  getAccessGroup(site: ID!, id: ID!): AccessGroup
}

type AccessGroup {
  id: ID!
  customerReference: String!
  lockCount: Int!
  userCount: Int!
  TimeSchedules: TimeSchedulesResults
}

On the REST Api access groups have time schedules but they're two different calls, and as I don't always need the latter, I think it's better to have it like this.

In SAM, I've tried this:

  GraphQLVBVAAPI:
      Type: AWS::Serverless::GraphQLApi
      Properties:
        SchemaUri: ./graphql/schema.graphql
        Resolvers:                                                 
          Query:
            getAccessGroup:
              Runtime:
                Name: APPSYNC_JS
                Version: "1.0.0"
              Pipeline:
                - lambdaResolver  
            AccessGroup:
              Runtime:
                Name: APPSYNC_JS
                Version: "1.0.0"
              Pipeline:
                - lambdaResolver

But then I get an error saying

No field named AccessGroup found on type Query

This is quite easy in the Console where I can just attach a resolver to the spesific field itself.

Any suggestions?

Metadata

Assignees

No one assigned

    Labels

    stage/needs-triageAutomatically applied to new issues and PRs, indicating they haven't been looked at.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions