aerogear / keycloak-connect-graphql

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

KeycloakSchemaDirectives seem to break with "graphql-tools": "^8.0.0", #128

Closed cjohn001 closed 2 years ago

cjohn001 commented 3 years ago

Hello together, i am currently trying to upgrade my backend. As i have read the open issue with apollo server 3 I thought I only migrate up to "apollo-server-express": "2.25.2" as long as the issue is not fixed.

I just found that when I migrate from "graphql-tools": 7.x to 8.x than the KeycloakSchemaDirectives break. I am getting the following error message:

Argument of type '{ typeDefs: any[]; schemaDirectives: SchemaDirectiveMap; resolvers: any; }' is not assignable to parameter of type 'IExecutableSchemaDefinition<any>'.
  Object literal may only specify known properties, and 'schemaDirectives' does not exist in type 'IExecutableSchemaDefinition<any>'.

79   schemaDirectives: KeycloakSchemaDirectives,

My code:

function createSchema(): GraphQLSchema {
    let schema = makeExecutableSchema({
        typeDefs: [KeycloakTypeDefs, typeDefs],
        schemaDirectives: KeycloakSchemaDirectives,
        resolvers
    });
    return schema;
}

I also tried passing directives as array, like described in the comment in code schemaDirectives:[KeycloakSchemaDirectives] but this also does not work. Would be great if someone could explain how to use the KeycloakSchemaDirectives with graphql-tools 8 onwards.

I found this article, seems like graphql-tools changed its interface for directives. However, did not help me to get it running. https://community.apollographql.com/t/what-is-up-with-schema-directives-right-now/1031/3

nvegater commented 3 years ago

Im also stuck here. How do we use Keycloak Schema directives with the new interface ?

jamiter commented 2 years ago

This has been documented in the README:

https://github.com/aerogear/keycloak-connect-graphql#apollo-server-express-3-support

so I guess this ticket can be closed.

cjohn001 commented 2 years ago

Yes, indeed can be closed