Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Unknown directive model" when setting up AWS Amplify GraphQL API in WebStorm

I'm using the following AWS Amplify tutorial for Angular:

https://docs.amplify.aws/start/getting-started/data-model/q/integration/angular#model-the-data-with-graphql-transform

When I generate the GraphQL API I get red warning messages for the @model directive:

enter image description here

I'm using WebStorm. How can I get my editor to not throw these red warning errors? Do I need to install some @types package or install some plugin?

like image 492
Weblurk Avatar asked Mar 02 '21 03:03

Weblurk


People also ask

How do I update the Amplify schema in GraphQL?

Once your API is deployed, updating the schema is easy with the CLI. You can edit the schema file(s) and run amplify push command to update your GraphQL backend. When you run the push command, you will notice that your schema change is automatically detected, and your backend will be updated respectively.

What is the difference between AppSync and amplify?

AWS Amplify can integrate with any GraphQL provider to perform queries and real-time data subscriptions via it's easy to use GraphQL client. AWS AppSync extends GraphQL's capabilities even more by offering enterprise-level security, real-time data synchronization, and orchestration of backend data resources.

What database does amplify use?

Amazon DynamoDB Although DynamoDB is Amplify DataStore's default database solution, developers can create AWS AppSync resolvers to use different purpose-built database offerings provided by AWS.


1 Answers

First, create .graphqlconfig file with the following content:

{
  "schemaPath": "schema.graphql",
  "includes": ["*"],
  "extensions": {
    "endpoints": {}
  }
}

Then, create graphql-directives.js file with the following content:

import gql from 'graphql-tag';

const clientSchemaExtensions = gql`
  directive @model on OBJECT
  scalar AWSDateTime
`;

After that, there are no syntax errors anymore!

enter image description here

This answer was adapted from this repo.

like image 123
Vlad Holubiev Avatar answered Oct 22 '22 23:10

Vlad Holubiev