aerogear / keycloak-connect-graphql

Add Keyloak Authentication and Authorization to your GraphQL server.
Apache License 2.0
157 stars 23 forks source link

Keycloak.GrantedRequest no longer existing in keycloak typings #70

Open wtrocki opened 4 years ago

dgarciap commented 4 years ago

Hello, I'm having an error related to this type on the next line: const kauth = new KeycloakContext({ req });

Error: Type 'Request<ParamsDictionary, any, any, ParsedQs>' is missing the following properties from type 'GrantedRequest': kauth, cache, credentials, destination, and 16 more

Is it solved?

I'm using: "keycloak-connect": "^11.0.0", "keycloak-connect-graphql": "^0.6.1",

heivo commented 4 years ago

@dgarciap have you found a solution? I'm having the same issue.

BasarN commented 4 years ago

same issue here, any workaround?

wtrocki commented 4 years ago

Strange. I cannot replicate that on sample app in the repo that uses the same version.

BasarN commented 4 years ago

@wtrocki I'm using

"typescript": "^4.0.3",
"graphql": "^15.4.0",
"keycloak-admin": "^1.13.0",
"keycloak-connect": "^11.0.2",
"keycloak-connect-graphql": "^0.6.3",

The problem seems to occur when I use import { KeycloakContext, KeycloakTypeDefs, KeycloakSchemaDirectives } from "keycloak-connect-graphql" Instead of const { KeycloakContext, KeycloakTypeDefs, KeycloakSchemaDirectives } = require('keycloak-connect-graphql')

I get cannot find name Request on GrantedRequest when using import

export interface GrantedRequest extends Request {
    kauth: {
        grant?: Grant;
    };
}
wtrocki commented 3 years ago

Our library exports our own typings. So typinings we can use should be coming from the library itself. https://github.com/aerogear/keycloak-connect-graphql/blob/master/src/KeycloakTypings.ts

wtrocki commented 3 years ago

Oh.. but you should have express types. I guess reexporting this doesn't sound like bad plan. Maybe we can create PR with the fix.

erikSenseworks commented 3 years ago

Woops deleted my last comment.

When adding import { Request } from 'express'; into KeycloakContext.d.ts everything works fine.
Do you have any tips what I can try/do to come around this problem?

To answer my question I'm currently using "@types/express": "^4.17.6"

wtrocki commented 3 years ago

I'm away from computer till next week so cannot check it. Sample app works. If you can add this to types and still make sample app work I can merge and resolve problem

BasarN commented 3 years ago

Did add import { Request } from 'express' into https://github.com/aerogear/keycloak-connect-graphql/blob/master/src/KeycloakContext.ts worked on sample app.

When you say types do you mean https://github.com/aerogear/keycloak-connect-graphql/blob/master/src/KeycloakTypings.ts ?

wtrocki commented 3 years ago

Superb. Sounds like PR will solve problem.. Will release it after

BasarN commented 3 years ago

thx for quick merge!