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

Failed to recognize directives input types #388

Closed
Hideman85 opened this issue Sep 11, 2020 · 6 comments
Closed

Failed to recognize directives input types #388

Hideman85 opened this issue Sep 11, 2020 · 6 comments
Labels
Milestone

Comments

@Hideman85
Copy link

image

schema.gql

type User
@model(mutations: { create: "createUser", update: "updateUser" })
@auth(rules: [{
  allow: owner,
  provider: userPools,
  ownerField: "id",
  identityClaim: "sub",
  operations: [update]
}])
{
  id: ID! @Check(values: ["$ctx.identity.sub"])
  firstName: String!
  lastName: String!
  avatar: File
  address: Address # @FilterOut(cond: { op: NOT_EQUAL, values: ["$ctx.identity.sub"] })
  phoneNumber: String # @FilterOut(cond: { op: NOT_EQUAL, values: ["$ctx.identity.sub"] })
  currentOrganisationID: ID # @ReadOnly # set by a lambda
}

awsDirectives.graphql

scalar AWSDate
scalar AWSTime
scalar AWSDateTime
scalar AWSTimestamp
scalar AWSEmail
scalar AWSJSON
scalar AWSURL
scalar AWSPhone
scalar AWSIPAddress

##########################################################
##          Model
##########################################################
directive @model(
  queries: ModelQueryMap
  mutations: ModelMutationMap
  subscriptions: ModelSubscriptionMap
  timestamps: TimestampConfiguration
) on OBJECT
input ModelMutationMap {
  create: String
  update: String
  delete: String
}
input ModelQueryMap {
  get: String
  list: String
}
input ModelSubscriptionMap {
  onCreate: [String]
  onUpdate: [String]
  onDelete: [String]
  level: ModelSubscriptionLevel
}
enum ModelSubscriptionLevel {
  off
  public
  on
}
input TimestampConfiguration {
  createdAt: String
  updatedAt: String
}

##########################################################
##          Auth
##########################################################
directive @auth(rules: [AuthRule!]!) on OBJECT | FIELD_DEFINITION
input AuthRule {
  allow: AuthStrategy!
  provider: AuthProvider
  ownerField: String # defaults to "owner" when using owner auth
  identityClaim: String # defaults to "username" when using owner auth
  groupClaim: String # defaults to "cognito:groups" when using Group auth
  groups: [String]  # Required when using Static Group auth
  groupsField: String # defaults to "groups" when using Dynamic Group auth
  operations: [ModelOperation] # Required for finer control

  # The following arguments are deprecated. It is encouraged to use the 'operations' argument.
  queries: [ModelQuery]
  mutations: [ModelMutation]
}
enum AuthStrategy { owner groups private public }
enum AuthProvider { apiKey iam oidc userPools }
enum ModelOperation { create update delete read }

# The following objects are deprecated. It is encouraged to use ModelOperations.
enum ModelQuery { get list }
enum ModelMutation { create update delete }

##########################################################
##          Key
##########################################################
directive @key(fields: [String!]!, name: String, queryField: String) on OBJECT

##########################################################
##          Connextion
##########################################################
directive @connection(keyName: String, fields: [String!]) on FIELD_DEFINITION

##########################################################
##          Function / Lambda
##########################################################
directive @function(name: String!, region: String) on FIELD_DEFINITION

##########################################################
##          Searchable / Elasticsearch
##########################################################
# Streams data from DynamoDB to Elasticsearch and exposes search capabilities.
directive @searchable(queries: SearchableQueryMap) on OBJECT
input SearchableQueryMap { search: String }

##########################################################
##          HTTP / Slack for ex
##########################################################
directive @http(method: HttpMethod, url: String!, headers: [HttpHeader]) on FIELD_DEFINITION
enum HttpMethod { PUT POST GET DELETE PATCH }
input HttpHeader {
  key: String
  value: String
}

The directives file is correctly included in .graphqlconfig and the directives don't have any issues. The issues come on the arguments of these directives and it looks like the plugin failed to find the input types. Can be related to #348

I'am using the latest WebStorm with the latest plugin version (2.6.0)

@vepanimas vepanimas added the bug label Sep 11, 2020
@vepanimas
Copy link
Collaborator

@Hideman85 hello, thank you for this report, I'll check it out.

@vepanimas
Copy link
Collaborator

@Hideman85 unfortunately, it turns out that resolving/completion object directive arguments is not supported at all at the moment. I checked it in the 2.4.0 version to be sure it is not a regression. So, it will take some time to implement it, I think the fix will be available in the next release.

@vepanimas vepanimas added this to the 2.7.0 milestone Sep 13, 2020
@vepanimas vepanimas removed this from the 2.7.0 milestone Dec 22, 2020
@dsypniewski
Copy link

I was having the same problem and in my testing it seems that as soon as any of the defined directives are invalid on the first level of input nested data types are not checked and marked as invalid, as soon as I've fixed the directive that was causing this the nested data types are checked.

@Hideman85 I see that you are using Amplify as am I, the problem in my case was the @connection directive which seem to be different in documentation and source code and should be instead:

directive @connection(
  name: String
  keyField: String
  sortField: String
  keyName: String
  limit: Int
  fields: [String!]
) on FIELD_DEFINITION

@dhyeyshah
Copy link

dhyeyshah commented Feb 12, 2021

Any updates on this front? This is still happening in the @auth directive of amplify. Even when we use this defination

type Note
  @model
  @auth(rules: [{ allow: owner }])
{
  id: ID!
  title: String
  content: String
}

directive @auth(
  rules: [AuthRule!]!
) on OBJECT

input AuthRule {
  allow: AuthStrategy!
  ownerField: String
  groups: [String]
  operations: [ModelOperation]
}

enum AuthStrategy { owner groups private public }

enum ModelOperation { create update delete read }

It will recognise "rules", but It will not recognise "allow" field within "rules". When can we expect this to be fixed?

@vepanimas vepanimas added this to the 3.0 milestone Apr 24, 2021
@noorulh06
Copy link

WebStorm is not able to recognise graphQL @client and @export directive.

@vepanimas
Copy link
Collaborator

Should be fixed in 3.0.0.

@noorulh06 Please, look at this comment #490 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants