Urigo/graphql-modules

GraphQL Modules issue with deps

tvvignesh opened this issue · 3 comments

Describe the bug

Hi. I deleted by yarn.lock file and node_modules just to reinstall all dependencies afresh and I was able to do that but an issue occurred with GraphQL Modules. I started getting this error below (I am using Dependency Injection)

image

And there is no change in the code or the environment when it was working and when it was not working - the only changes are in yarn.lock and thus the dependencies themselves (when I roll back to the old yarn.lock everything works). Can you help on why it breaks on upgrade?

To Reproduce
Steps to reproduce the behavior:

**Working yarn.lock file: ** https://gist.github.com/tvvignesh/cc043ae59c18fd3920fdeb9bb8b615a0#file-yarn-working-lock

**yarn.lock file with issue: ** https://gist.github.com/tvvignesh/cc043ae59c18fd3920fdeb9bb8b615a0#file-yarn-notworking-lock

Expected behavior

Expecting GraphQL modules to work even on dependency upgrades

Environment:

  • OS: Ubuntu 22.04

**PS: ** I use yarn 2 for install

@n1ru4l @kamilkisiela @ardatan GraphQL Modules Dependency Injection with @envelop/graphql-modules or one of the dependencies from my yarn lock has crazy bug in this release - for instance, the injector loads a different provider when you try to load a different provider and this varies based on the sequence of modules in createApplication. Rolling back to previous version

For instance, if I log context.injector.get(Member) and I just change the sequence of modules in the application, this is how the log changes

THIS WORKS

Member {
    context: {
        request: Request {
        size: 0,
        timeout: 0,
        follow: 20,
        compress: true,
        counter: 0,
        agent: undefined,
        formData: [Function: formData],
        [Symbol(Body internals)]: [Object],
        [Symbol(Request internals)]: [Object]
        },
        operationName: 'listMembers',
        query: 'query listMembers {\n' +
        '\tmembers {\n' +
        '\t\tkey\n' +
        '\t\tusername\n' +
        '\t\tname\n' +
        '\t\temail\n' +
        '\t\tphone\n' +
        '\t\tpictureUrl\n' +
        '\t\tcreatedDate\n' +
        '\t}\n' +
        '}\n',
        variables: undefined,
        extensions: undefined,
        req: _Request {
        id: 'req-5',
        context: [Context],
        params: {},
        raw: [IncomingMessage],
        query: {},
        log: [EventEmitter],
        body: [Object],
        corsPreflightEnabled: false,
        tmpUploads: null,
        [Symbol(fastify.RequestPayloadStream)]: [IncomingMessage]
        },
        reply: _Reply {
        raw: [ServerResponse],
        request: [_Request],
        log: [EventEmitter],
        [Symbol(fastify.reply.isError)]: false,
        [Symbol(fastify.reply.errorHandlerCalled)]: false,
        [Symbol(fastify.reply.hijacked)]: false,
        [Symbol(fastify.reply.serializer)]: null,
        [Symbol(fastify.reply.headers)]: [Object],
        [Symbol(fastify.reply.trailers)]: null,
        [Symbol(fastify.reply.startTime)]: 5102031.987665,
        [Symbol(fastify.reply.endTime)]: undefined
        },
        user: {
        _key: '36a0e51f-7a27-4aa9-9810-3cfe1552eef3',
        name: 'Vignesh T.V',
        username: 'vignesh',
        email: 'vignesh@burdenoff.com'
        },
        tenant: {
        activeWorkspaceKey: '9c2456b7-1041-4314-97ec-0dd944304e00',
        tenantURI: 'tenant-1'
        },
        workspace: WorkspaceDB {
        url: 'http://core-tenant-arangodb:8529',
        workspaceURI: 'test-wspace3',
        dbname: 'tcnKyzgHSYogsZXT0',
        dbusername: 'fRqRNNrpdda0wLp',
        dbpassword: 'h4kvLzfnvahDGxU',
        db: [Database],
        entity: [Entity],
        graph: [TCGraph]
        },
        'ɵgetModuleContext': [Function: getModuleContext],
        injector: ReflectiveInjector {
        _constructionCounter: 2,
        _executionContextGetter: [Function: notInExecutionContext],
        displayName: 'Module "member" (Operation Scope)',
        _parent: [ReflectiveInjector],
        _fallbackParent: [ReflectiveInjector],
        _providers: [Array],
        _globalProvidersMap: Map(0) {},
        _keyIds: [Array],
        _objs: [Array]
        },
        moduleId: 'member',
        [Symbol(promPluginExecutionStartTimeSymbol)]: 1662101684678,
        [Symbol(rawDocument)]: 'query listMembers {\n' +
        '\tmembers {\n' +
        '\t\tkey\n' +
        '\t\tusername\n' +
        '\t\tname\n' +
        '\t\temail\n' +
        '\t\tphone\n' +
        '\t\tpictureUrl\n' +
        '\t\tcreatedDate\n' +
        '\t}\n' +
        '}\n',
        [Symbol(promPluginContext)]: {
        document: [Object],
        operationName: 'listMembers',
        operationType: 'query'
        },
        [Symbol(GRAPHQL_MODULES)]: {
        context: [Object],
        injector: [ReflectiveInjector],
        destroy: [Function (anonymous)],
        'ɵdestroy': [Function (anonymous)]
        },
        [Symbol(RESOLVERS_HOOKS)]: [ [Function (anonymous)] ]
    },
    data: Data {
        context: {
        request: [Request],
        operationName: 'listMembers',
        query: 'query listMembers {\n' +
            '\tmembers {\n' +
            '\t\tkey\n' +
            '\t\tusername\n' +
            '\t\tname\n' +
            '\t\temail\n' +
            '\t\tphone\n' +
            '\t\tpictureUrl\n' +
            '\t\tcreatedDate\n' +
            '\t}\n' +
            '}\n',
        variables: undefined,
        extensions: undefined,
        req: [_Request],
        reply: [_Reply],
        user: [Object],
        tenant: [Object],
        workspace: [WorkspaceDB],
        'ɵgetModuleContext': [Function: getModuleContext],
        injector: [ReflectiveInjector],
        moduleId: 'member',
        [Symbol(promPluginExecutionStartTimeSymbol)]: 1662101684678,
        [Symbol(rawDocument)]: 'query listMembers {\n' +
            '\tmembers {\n' +
            '\t\tkey\n' +
            '\t\tusername\n' +
            '\t\tname\n' +
            '\t\temail\n' +
            '\t\tphone\n' +
            '\t\tpictureUrl\n' +
            '\t\tcreatedDate\n' +
            '\t}\n' +
            '}\n',
        [Symbol(promPluginContext)]: [Object],
        [Symbol(GRAPHQL_MODULES)]: [Object],
        [Symbol(RESOLVERS_HOOKS)]: [Array]
        },
        db: Database {
        _analyzers: Map(0) {},
        _collections: [Map],
        _graphs: [Map],
        _views: Map(0) {},
        _connection: [Connection],
        _name: 'tcnKyzgHSYogsZXT0'
        }
    }
    }

THIS DOES NOT WORK

Looks like its loading a different provider (Workspace) when I ask for member just when changing the sequence within application

Workspace {
   context: {
     request: Request {
       size: 0,
       timeout: 0,
       follow: 20,
       compress: true,
       counter: 0,
       agent: undefined,
       formData: [Function: formData],
       [Symbol(Body internals)]: [Object],
       [Symbol(Request internals)]: [Object]
     },
     operationName: 'listMembers',
     query: 'query listMembers {\n' +
       '\tmembers {\n' +
       '\t\tkey\n' +
       '\t\tusername\n' +
       '\t\tname\n' +
       '\t\temail\n' +
       '\t\tphone\n' +
       '\t\tpictureUrl\n' +
       '\t\tcreatedDate\n' +
       '\t}\n' +
       '}\n',
     variables: undefined,
     extensions: undefined,
     req: _Request {
       id: 'req-1',
       context: [Context],
       params: {},
       raw: [IncomingMessage],
       query: {},
       log: [EventEmitter],
       body: [Object],
       corsPreflightEnabled: false,
       tmpUploads: null,
       [Symbol(fastify.RequestPayloadStream)]: [IncomingMessage]
     },
     reply: _Reply {
       raw: [ServerResponse],
       request: [_Request],
       log: [EventEmitter],
       [Symbol(fastify.reply.isError)]: false,
       [Symbol(fastify.reply.errorHandlerCalled)]: false,
       [Symbol(fastify.reply.hijacked)]: false,
       [Symbol(fastify.reply.serializer)]: null,
       [Symbol(fastify.reply.headers)]: [Object],
       [Symbol(fastify.reply.trailers)]: null,
       [Symbol(fastify.reply.startTime)]: 5217038.930842,
       [Symbol(fastify.reply.endTime)]: undefined
     },
     user: {
       _key: '36a0e51f-7a27-4aa9-9810-3cfe1552eef3',
       name: 'Vignesh T.V',
       username: 'vignesh',
       email: 'vignesh@burdenoff.com'
     },
     tenant: {
       activeWorkspaceKey: '9c2456b7-1041-4314-97ec-0dd944304e00',
       tenantURI: 'tenant-1'
     },
     workspace: WorkspaceDB {
       url: 'http://core-tenant-arangodb:8529',
       workspaceURI: 'test-wspace3',
       dbname: 'tcnKyzgHSYogsZXT0',
       dbusername: 'fRqRNNrpdda0wLp',
       dbpassword: 'h4kvLzfnvahDGxU',
       db: [Database],
       entity: [Entity],
       graph: [TCGraph]
     },
     'ɵgetModuleContext': [Function: getModuleContext],
     injector: ReflectiveInjector {
       _constructionCounter: 2,
       _executionContextGetter: [Function: notInExecutionContext],
       displayName: 'Module "workspace" (Operation Scope)',
       _parent: [ReflectiveInjector],
       _fallbackParent: [ReflectiveInjector],
       _providers: [Array],
       _globalProvidersMap: Map(0) {},
       _keyIds: [Array],
       _objs: [Array]
     },
     moduleId: 'workspace',
     [Symbol(promPluginExecutionStartTimeSymbol)]: 1662101799701,
     [Symbol(rawDocument)]: 'query listMembers {\n' +
       '\tmembers {\n' +
       '\t\tkey\n' +
       '\t\tusername\n' +
       '\t\tname\n' +
       '\t\temail\n' +
       '\t\tphone\n' +
       '\t\tpictureUrl\n' +
       '\t\tcreatedDate\n' +
       '\t}\n' +
       '}\n',
     [Symbol(promPluginContext)]: {
       document: [Object],
       operationName: 'listMembers',
       operationType: 'query'
     }
   },
   member: Member {
     context: {
       request: [Request],
       operationName: 'listMembers',
       query: 'query listMembers {\n' +
         '\tmembers {\n' +
         '\t\tkey\n' +
         '\t\tusername\n' +
         '\t\tname\n' +
         '\t\temail\n' +
         '\t\tphone\n' +
         '\t\tpictureUrl\n' +
         '\t\tcreatedDate\n' +
         '\t}\n' +
         '}\n',
       variables: undefined,
       extensions: undefined,
       req: [_Request],
       reply: [_Reply],
       user: [Object],
       tenant: [Object],
       workspace: [WorkspaceDB],
       'ɵgetModuleContext': [Function: getModuleContext],
       injector: [ReflectiveInjector],
       moduleId: 'member',
       [Symbol(promPluginExecutionStartTimeSymbol)]: 1662101799701,
       [Symbol(rawDocument)]: 'query listMembers {\n' +
         '\tmembers {\n' +
         '\t\tkey\n' +
         '\t\tusername\n' +
         '\t\tname\n' +
         '\t\temail\n' +
         '\t\tphone\n' +
         '\t\tpictureUrl\n' +
         '\t\tcreatedDate\n' +
         '\t}\n' +
         '}\n',
       [Symbol(promPluginContext)]: [Object],
       [Symbol(GRAPHQL_MODULES)]: [Object],
       [Symbol(RESOLVERS_HOOKS)]: [Array]
     },
     data: Data { context: [Object], db: [Database] }
   },
   entity: Entity {
     db: Database {
       _analyzers: Map(0) {},
       _collections: [Map],
       _graphs: [Map],
       _views: Map(0) {},
       _connection: [Connection],
       _name: 'tcnKyzgHSYogsZXT0'
     },
     member: Member {
       modelName: 'member',
       collection: [Collection],
       workspaceDB: [Database]
     },
     workspace: Workspace {
       modelName: 'workspace',
       collection: [Collection],
       workspaceDB: [Database]
     },
     installedChannel: InstalledChannel {
       modelName: 'installed-channel',
       collection: [Collection],
       workspaceDB: [Database]
     },
     workspaceMember: WorkspaceMember {
       modelName: 'workspace_member',
       collection: [Collection],
       workspaceDB: [Database]
     },
     event: Event {
       modelName: 'event',
       collection: [Collection],
       workspaceDB: [Database]
     },
     channelToEvents: InstalledChannelToEvent {
       modelname: 'installed_channel_to_event',
       collection: [Collection],
       workspaceDB: [Database]
     },
     page: Page {
       modelName: 'page',
       collection: [Collection],
       workspaceDB: [Database]
     },
     pageVersion: PageVersion {
       modelName: 'pageVersion',
       collection: [Collection],
       workspaceDB: [Database]
     },
     pageVersionEdge: VersionsInPageEdge {
       modelName: 'page_version_edge',
       collection: [Collection],
       workspaceDB: [Database]
     },
     childOfEntityEdge: ChildOfEntityEdge {
       modelName: 'child_entity_edge',
       collection: [Collection],
       workspaceDB: [Database]
     }
   },
   data: Data {
     context: {
       request: [Request],
       operationName: 'listMembers',
       query: 'query listMembers {\n' +
         '\tmembers {\n' +
         '\t\tkey\n' +
         '\t\tusername\n' +
         '\t\tname\n' +
         '\t\temail\n' +
         '\t\tphone\n' +
         '\t\tpictureUrl\n' +
         '\t\tcreatedDate\n' +
         '\t}\n' +
         '}\n',
       variables: undefined,
       extensions: undefined,
       req: [_Request],
       reply: [_Reply],
       user: [Object],
       tenant: [Object],
       workspace: [WorkspaceDB],
       'ɵgetModuleContext': [Function: getModuleContext],
       injector: [ReflectiveInjector],
       moduleId: 'workspace',
       [Symbol(promPluginExecutionStartTimeSymbol)]: 1662101799701,
       [Symbol(rawDocument)]: 'query listMembers {\n' +
         '\tmembers {\n' +
         '\t\tkey\n' +
         '\t\tusername\n' +
         '\t\tname\n' +
         '\t\temail\n' +
         '\t\tphone\n' +
         '\t\tpictureUrl\n' +
         '\t\tcreatedDate\n' +
         '\t}\n' +
         '}\n',
       [Symbol(promPluginContext)]: [Object]
     },
     member: Member { context: [Object], data: [Data] },
     db: Database {
       _analyzers: Map(0) {},
       _collections: [Map],
       _graphs: [Map],
       _views: Map(0) {},
       _connection: [Connection],
       _name: 'tcnKyzgHSYogsZXT0'
     }
   }
 }