oneclickdapp / ethereum-auth

55 stars 6 forks source link

Unknown type "AuthChallengeInput" #12

Open kf106 opened 1 year ago

kf106 commented 1 year ago

I'm getting an error in the client, "Error @oneclickdapp/ethereum-auth login(): Error: Couldn't get auth challenge from your server. See above error for more details" which I presume is because of the following error on the server:

api | 12:08:58 🚨 graphql-server Unknown type "AuthChallengeInput".
api | 12:08:58 🚨 graphql-server Cannot query field "authChallenge" on type "Mutation".

I can see that ethereumAuth.js is supposed to provide the challenge, but I'm guessing something isn't updated in the gql types, or isn't set up properly, when following the README.md.

pi0neerpat commented 1 year ago

Do you have this in your sdl? https://github.com/oneclickdapp/ethereum-auth/blob/e7010d08c5d25424dedf6ad1d39b122786cc77bc/examples/eth-auth-demo/api/src/graphql/ethereumAuth.sdl.js#L10

It might need to be changed from 'input' to 'type'

wispyco commented 1 year ago

I think this sdl may not be correct.

https://github.com/oneclickdapp/ethereum-auth/blob/master/examples/eth-auth-demo/api/src/graphql/authDetails.sdl.js

I combined the one you linked with this one to get this and it did work

export const schema = gql`
  type AuthDetail {
    id: String!
    nonce: String!
    timestamp: DateTime!
    User: User
  }
  type Query {
    authDetails: [AuthDetail!]! @skipAuth
  }
  input CreateAuthDetailInput {
    nonce: String!
    timestamp: DateTime!
  }
  input UpdateAuthDetailInput {
    nonce: String
    timestamp: DateTime
  }
  type AuthChallengeResult {
    message: String!
  }
  type AuthVerifyResult {
    token: String!
  }
  input AuthChallengeInput {
    address: String!
    options: JSON
  }
  input AuthVerifyInput {
    signature: String!
    address: String!
    options: JSON
  }

  type Mutation {
    authChallenge(input: AuthChallengeInput!): AuthChallengeResult @skipAuth
    authVerify(input: AuthVerifyInput!): AuthVerifyResult @skipAuth
  }
`