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

Amplify API: Model based APIs and OIDC support #308

Closed
fjnoyp opened this issue Jan 15, 2021 · 24 comments
Closed

Amplify API: Model based APIs and OIDC support #308

fjnoyp opened this issue Jan 15, 2021 · 24 comments
Assignees
Labels
feature-request A request for a new feature or an enhancement to an existing API or category. GraphQL API Issues related to the API (GraphQL) Category

Comments

@fjnoyp
Copy link
Contributor

fjnoyp commented Jan 15, 2021

The current version of Amplify API has some features that will be supported in the future:

  1. OIDC support : https://docs.amplify.aws/lib/restapi/authz/q/platform/android#cognito-user-pool-authorization

  2. GraphQL Request Helpers that automatically generate GraphQL requests for you. Instead, you need to create the GraphQL request document yourself when calling the API.
    (ie. only Advanced Workflows is supported: https://docs.amplify.aws/lib/graphqlapi/advanced-workflows/q/platform/android)

  3. GraphQL Subscriptions

@fjnoyp fjnoyp added the feature-request A request for a new feature or an enhancement to an existing API or category. label Jan 15, 2021
@fjnoyp fjnoyp assigned fjnoyp and Ashish-Nanda and unassigned fjnoyp Jan 15, 2021
@Ashish-Nanda Ashish-Nanda changed the title Amplify API - Missing features: OIDC / Request Helpers Amplify API: Model based APIs and OIDC support Jan 15, 2021
@rlee1990
Copy link

Is there a timeline on GraphQL Request Helpers?

@JuanDelgadillo
Copy link

Hey heyy guys! Does someone know alternative ways of automatically generating GraphQL Request Helpers?

I am thinking of automatically generating them in JavaScript and then translating them to Dart... but I am not sure if this will work, I'll test it out and comment back how it went.

If you know other more efficient ways of doing this, please let us know.

Thanks in advance.

Cheers!

@cto-leaps
Copy link

cto-leaps commented Mar 28, 2021

Hey guys,

The doc at this url
shows a way to use different auth modes for the same GraphQL Endpoint, which is exactly what I am looking for.

{
    "UserAgent": "aws-amplify-cli/2.0",
    "Version": "1.0",
    "api": {
        "plugins": {
            "awsAPIPlugin": {
                "[FRIENDLY-NAME-API-WITH-IAM": {
                    "endpointType": "GraphQL",
                    "endpoint": "[GRAPHQL-ENDPOINT]",
                    "region": "[REGION]",
                    "authorizationType": "AWS_IAM",
                },
                "[FRIENDLY-NAME-API-WITH-USER-POOLS]": {
                    "endpointType": "GraphQL",
                    "endpoint": "https://xyz.appsync-api.us-west-2.amazonaws.com/graphql",
                    "region": "[REGION]",
                    "authorizationType": "AMAZON_COGNITO_USER_POOLS",
                },
            }
        }
    }
}

One model in my scheme is set as follows:

type Exercise
  @model(subscriptions: null)
  @searchable
  @auth(rules: [
    {allow: groups, groups: ["Athletes"], operations: [read]}
    {allow: groups, groups: ["Administrators"], operations: [create, read, update, delete]}
    {allow: public, provider: iam, operations: [read] }
  ])
   @key(name: "sortedByNameEN", fields: ["points", "nameEN"], queryField: "exerciseSortedByNameEN")
   @key(name: "byCategory", fields: ["categoryID", "id"])
{ 
  id: ID!
  nameEN: String!
 [...]
  points: Int
  createdAt: AWSDateTime
  updatedAt: AWSDateTime
}

So I want my Guest Users (the ones who have not yet created an account) to be able to get a list of Exercices, just like the Authenticated ones.
The doc suggests that I should be able to switch which auth to use by using the "friendly_api_name", however, I can't seem to find anywhere how to do that.

Is it not available yet? Upcoming? Any workaround?
Am I going about this the wrong way?

I am asking here, as the doc is pointing to this issue. Feel free to push me towards the right direction...
🙏

@segoto
Copy link

segoto commented Apr 7, 2021

Hey guys, I'm kind of having some troubles using the API with graphql because the default token used for the api is the access token but in our backend we already have implemented with the idToken and this won't let me retrieve the data for the app. Meanwhile I'm using the amazon_cognito_identity_dart_2 to implement the queries with http package. I don't know if you may have another way?

@ESRuth
Copy link

ESRuth commented Apr 19, 2021

Is this on the roadmap, anywhere?

@rlee1990
Copy link

@Amplifiyer any updates?

@jodafm
Copy link
Contributor

jodafm commented Apr 29, 2021

@cto-leaps do you find a solution?
I don't know where to put the apiName.

@AbeerISSP
Copy link

How is this looking?

@cto-leaps
Copy link

@jodafm Nope. I had to turn the whole thing around and have a local Exercise DB installed with the app. Quite a nuisance and a waste of time, tbh.

@ragingsquirrel3 ragingsquirrel3 added the GraphQL API Issues related to the API (GraphQL) Category label Jun 3, 2021
@Dachmian
Copy link

Dachmian commented Jun 4, 2021

Any news about this?
Does anyone have a workaround for using AWS Appsync with amplify libraries?

It is not possible for us to use Amplify CLI for our project for a number of reasons so we use CDK to provision our cloud. However this forces us to write the queries and parsers manually in our Flutter app which is time consuming and will only get worse over time as the API grows and changes happen

@filippomenchini
Copy link

Any updates on this?
It would be cool to see this feature available soon 😄

@omartinma
Copy link

Any plan to update soon? Really needed this :D Thanks!

@alefl10
Copy link

alefl10 commented Nov 18, 2021

It'd be awesome to have this feature available soon! Any updates on the timeline? Thank you 😄

@ESRuth
Copy link

ESRuth commented Nov 18, 2021

In taking a step back, and deciding what avenue to take on a project if this didn't exist, I discovered that DataStore (https://docs.amplify.aws/lib/datastore/getting-started/q/platform/flutter/) is the answer, at least to my problems.

@dnys1
Copy link
Contributor

dnys1 commented Nov 18, 2021

It seems like most people are waiting for GraphQL model helpers - rest assured they are coming shortly! As for the other two points mentioned, OIDC and GraphQL subscriptions, these are both available currently. As @ESRuth mentions - DataStore is another alternative available.

@filippomenchini
Copy link

Nice! Can't wait.
Yeah, I know DataStore, but i don't want to sync data offline, since I'm building a social media app.
In addiction, DataStore on Flutter is not so good to me, It has a few bugs that make me very insecure using It in a production env.
For now, I'm going to stick with Lambda functions and GraphQL. Hope to see this helpers come to life soon!

Thanks!

@dnys1
Copy link
Contributor

dnys1 commented Nov 18, 2021

Thank you for the feedback, @filippomenchini. We are continuously working hard to make DataStore more reliable and stable for production workloads. I hope you check back in at some point to see if it has improved to fit your use case, and please always feel free to share any issues you run into along the way.

That said, we are certainly excited for the improvements that GraphQL helpers will bring for the more customized workflows which DataStore cannot fill.

@filippomenchini
Copy link

I'm constantly looking on DataStore improvements, I really like it. But in my use case is not ideal.
I tried to use It, but It gave me some problems.
I don't know if my problems are related to a bug, or to the way I intend to use DataStore.
Before the week ends, I'll ask some questions on the Discord server to see what is the problem, and if It turns out to be a bug, i'll open an issue.

Thanks again for the support, @dnys1 !

@abdallahshaban557
Copy link
Contributor

@filippomenchini - I would love to hear more about the issues you are facing as well! We are trying to understand where the gaps are with Datastore for our developers. You can reach out to me on discord at AbdallahShaban#4744 or on twitter at @AbdallahSh07

@ragingsquirrel3
Copy link
Contributor

We are happy to announce the release of model-based GraphQL helpers with amplify-flutter version 0.4.0. Our API getting started guide has been updated to use model helpers at https://docs.amplify.aws/lib/graphqlapi/getting-started/q/platform/flutter/, although manual string-based requests are still supported. With that, I will close this issue. Please file new issues for any problems/requests you may encounter while integrating this into your project.

Shoutout to our intern from last summer @Equartey as this was his intern project and he did a great job.

@jamesblasco
Copy link

I have just tried it and it only generates empty files for me. Enum types are correctly generated but the rest (object, queries, mutations types) generates empty files.
The code generator completes successfully with no error

amplify cli version: 7.6.21
dart: 2.16
flutter 2.10

Screenshot 2022-02-18 at 17 55 02

@ragingsquirrel3
Copy link
Contributor

@jamesblasco is the Book object in screenshot above your whole schema? If not, do you mind putting a copy of your schema here so we can try to repro? At first glance, I noticed there is no @model directive after the work "Book" in your schema which might explain the error (see Todo example), but if not, we can spend more time trying to reproduce. Also, wanna double check all the amplify plugin versions are at least 0.4.0 in your pubpsec and that you have successfully run flutter pub get before running amplify codegen models.

@Dachmian
Copy link

@ragingsquirrel3
We have defined our schema in a schema.graphql and use CDK to deploy it to AWS AppSync. This schema does not use aws amplify directives such as @model or @connection. Based on your previous comment it sounds like this usecase is not covered?

@ragingsquirrel3
Copy link
Contributor

ragingsquirrel3 commented Feb 22, 2022

@Dachmian using the model helpers without an amplify schema (and resulting compiled appsync schema) is not a supported use case. While it might be possible to workaround, here are some things to be aware of:

  1. As mentioned above, the amplify codegen models command depends on having an amplify schema as it looks for certain directives (the simplest being "model"). If you want the codegen models (needed for model helpers) I think you would need to try creating an amplify codegen schema, adding locally with CLI and running the codegen command, then deleting the schema, removing anything added locally with the CLI. Again, this isn't really supported so would suggest doing this with temporary/non-production amplify backend just to get the model generated.
  2. With the model generated, you will be able to use the model helpers to generate requests but the requests might not resolve correctly with your appsync backend. The preformatted graphql requests are tightly coupled with the compiled graphql schema created by the amplify graphql transformer in the CLI. For example, simple list queries contain phrases like "listTodos" that are expected to be resolvers in your compiled graphql schema from the Amplify CLI. There are many more examples of this, especially when generating mutation requests as there is expected types/shapes for variables.

After all this, not sure what benefits you would have and difficult to say which requests would work with your schema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A request for a new feature or an enhancement to an existing API or category. GraphQL API Issues related to the API (GraphQL) Category
Projects
None yet
Development

No branches or pull requests