aws-amplify / amplify-category-api

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development. This plugin provides functionality for the API category, allowing for the creation and management of GraphQL and REST based backends for your amplify project.
https://docs.amplify.aws/
Apache License 2.0
87 stars 73 forks source link

Custom data source with @model (existing DynamoDB table) #454

Open alukach opened 5 years ago

alukach commented 5 years ago

Which Category is your question related to?

GraphQL Schema Transformer

What AWS Services are you utilizing?

DynamoDB, AppSync

Provide additional details e.g. code snippets

I already have a number of DynamoDB tables for which I would like to build a GraphQL API. The Amplify CLI's automated creation of queries and mutations is very appealing, as I would assume that I would be able to describe my model in schema.graphql and then run amplify api gql-compile to create all of the Resolvers and Data Sources. Is this at all possible? I can find no examples of arguments being passed to the @model decorator. I do see that in the GraphQL Transformer Tutorial it mentions a prompt for using your own table when adding an API:

# When asked if you want to use your own Amazon DynamoDB tables, choose **No**.

However, when creating an API with CLI version 0.1.16 I do not get such a prompt.

alukach commented 5 years ago

Possibly related to aws-amplify/amplify-cli#80

blbradley commented 5 years ago

I read the tutorials and expected this feature to be available when needed. But, it's not.

Any thoughts how this should be approached?

blbradley commented 5 years ago

I'm thinking a parameter on the @model directive would be a nice approach.

undefobj commented 5 years ago

@blbradley part of the design goals of the Transformer is to abstract away implementation so that you can just focus on your GraphQL data model. However Amplify also gives escape hatches where possible, so you can always have your own Transformer and do a specific implementation with other data sources. A tutorial for that is here: https://github.com/aws-amplify/amplify-cli/blob/master/how-to-write-a-transformer.md

Additionally as @alukach mentioned we're working on a Custom Resolvers flow that will allow more of the implementation specific capabilities. You can comment on that thread with your requirements here: https://github.com/aws-amplify/amplify-cli/issues/74

blbradley commented 5 years ago

I appreciate that design goal. My use case is adding an additional, public GraphQL API based upon an existing private GraphQL API/data model/tables built with amplify-cli.

SNK47 commented 1 year ago

To connect my existing DynamoDB table as a data source in my amplify graphql schema how to do that?