GithubHelp home page GithubHelp logo

urigo / graphql-modules Goto Github PK

View Code? Open in Web Editor NEW
1.3K 25.0 112.0 16.43 MB

Enterprise Grade Tooling For Your GraphQL Server

Home Page: https://graphql-modules.com/

License: MIT License

TypeScript 68.91% JavaScript 1.57% Dockerfile 0.94% Shell 3.17% MDX 25.42%
graphql graphql-server apollo apollo-server modules typescript dependency-injection

graphql-modules's People

Contributors

72636c avatar albert-lo avatar alinsimoc avatar ardatan avatar aretecode avatar charlypoly avatar dab0mb avatar dandv avatar danielrearden avatar darkbasic avatar dependabot[bot] avatar dimamachina avatar dotansimha avatar enisdenjo avatar gilgardosh avatar github-actions[bot] avatar kamilkisiela avatar kesslerdev avatar knpwrs avatar maapteh avatar n1ru4l avatar pabloszx avatar renovate-bot avatar renovate[bot] avatar saihaj avatar shiatsumat avatar tuvalsimha avatar tvvignesh avatar urigo avatar zomble avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

graphql-modules's Issues

0.2.12 > 0.2.13 breaking change (extraSchemas)

Hi!
I updated from 0.12.12 to 0.2.13 and my app suddenly doesn't work anymore.
I am using typescript and this is the error being outputted:

/Users/dodas/dev/fakture/packages/server/node_modules/@graphql-modules/core/dist/graphql-module.js:478
            finally { if (e_2) throw e_2.error; }
                               ^

TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined
    at Object.__values (/Users/dodas/dev/fakture/packages/server/node_modules/tslib/tslib.js:144:50)
    at GraphQLModule.buildSchemaAndInjector (/Users/dodas/dev/fakture/packages/server/node_modules/@graphql-modules/core/dist/graphql-module.js:459:55)
    at GraphQLModule.get [as resolvers] (/Users/dodas/dev/fakture/packages/server/node_modules/@graphql-modules/core/dist/graphql-module.js:168:22)
    at Module../src/graphql/index.ts (/Users/dodas/dev/fakture/packages/server/dist/index.js:4938:5)
    at __webpack_require__ (/Users/dodas/dev/fakture/packages/server/dist/index.js:21:30)
    at Module../src/pdf-renderer/index.ts (/Users/dodas/dev/fakture/packages/server/dist/index.js:7370:66)
    at __webpack_require__ (/Users/dodas/dev/fakture/packages/server/dist/index.js:21:30)
    at Module../src/index.ts (/Users/dodas/dev/fakture/packages/server/dist/index.js:7014:71)
    at __webpack_require__ (/Users/dodas/dev/fakture/packages/server/dist/index.js:21:30)
    at Object.0 (/Users/dodas/dev/fakture/packages/server/dist/index.js:7686:18)

it seems to have something to do with the new extraSchemas option, which I am not using.
any ideas?

thanks.

[Bug] Context is built every time the module is imported

In this tutorial, there is a part where we use GraphQL Modules to build the currentUser context. The recommendation is to create a AuthModule and import it in every module we need to authenticate the user. But... there is a problem.

Every time we import a module into another module, the context is built. So, if we are making DB queries, we're going to make 3, 4, 5, db calls in every request.

A workaround is to create a service using ProviderScope.Session and store the user data in the class property and use it if exists. Is this the expected behavior?

Documentation about features

  • - OnRequest hook
  • - Encapsulation
  • - Circular Dependency
  • - Authentication
  • - Option factories (Passing configuration or schema to option factories)
  • - Logger Interface
  • - Middlewares
  • - Provider scopes and ModuleSessionInfo
  • - DI in factory functions ( InjectFunction wrapper function )
  • - DataSources support
  • - DirectiveResolvers and SchemaDirectives
  • - Prisma integration #209

question(docs): how to merge typeDefs & resolvers

I'm slightly confused at the paramters passed to GraphQLModule. When importing modules, it works but then I wonder what the purpose of the typeDefs and resolvers fields are for, if the imports field internally manages merging type definitions and resolvers.

I also know that I could import all of my resolvers and type definitions using array notation on each module. IE: resolvers: [ArticleModule['resolvers'], UserModule['resolvers']],

I know this is a question but I've spent a bit of time puzzled on this so this question will turn into a PR for updating docs. Thanks!

Here's my main.ts (entry point)

import { GraphQLModule } from '@graphql-modules/core';
import { ApolloServer } from 'apollo-server';
import { ArticleModule } from './modules/ArticleModule';
import { UserModule } from './modules/UserModule';

const { schema, context } = new GraphQLModule({
  typeDefs: [],
  resolvers: [],
  imports: [ArticleModule, UserModule],
});

const server = new ApolloServer({
  schema,
  context,
});

server.listen().then(({ url }) => {
  console.log(`🚀  Server ready at ${url}`);
});

Add support of Object Extensions

I was playing awhile with basic-with-dependency-injection example and suddenly figuerd out that it seems that for now there is some issue with operation on type extension feature of graphQL.

Here is the section from the specification: https://facebook.github.io/graphql/draft/#sec-Object-Extensions wich describes particularly Object type extensions.

I'm defining the Query type on AppModule
screen shot 2019-01-14 at 4 29 56 pm

In the typeDefs section of the User module I want to extend the Query type I defined earlier
screen shot 2019-01-14 at 4 30 03 pm

But when I start an application, it crashes with an error
screen shot 2019-01-14 at 4 30 28 pm

Full error log is the following

(node:16478) UnhandledPromiseRejectionWarning: Error: 
      GraphQL-Modules Error: Schema is not valid!
      - #Module #149487813956593 doesn't have a valid schema!
      -- Cannot extend type "Query" because it does not exist in the existing schema.

      Possible solutions:
      - Check syntax errors in typeDefs
      - Make sure you import correct dependencies
    
    at GraphQLModule.buildSchemaAndInjector (/Users/ifeature/Desktop/graphql-modules/examples/basic-with-dependency-injection/node_modules/@graphql-modules/core/src/graphql-module.ts:483:17)
    at GraphQLModule.buildSchemaAndInjector (/Users/ifeature/Desktop/graphql-modules/examples/basic-with-dependency-injection/node_modules/@graphql-modules/core/src/graphql-module.ts:414:16)
    at GraphQLModule.get [as schema] (/Users/ifeature/Desktop/graphql-modules/examples/basic-with-dependency-injection/node_modules/@graphql-modules/core/src/graphql-module.ts:177:12)
    at Object.<anonymous> (/Users/ifeature/Desktop/graphql-modules/examples/basic-with-dependency-injection/src/server.ts:5:31)
    at Generator.next (<anonymous>)
    at /Users/ifeature/Desktop/graphql-modules/examples/basic-with-dependency-injection/src/server.ts:7:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/ifeature/Desktop/graphql-modules/examples/basic-with-dependency-injection/src/server.ts:3:12)
    at Object.bootstrap (/Users/ifeature/Desktop/graphql-modules/examples/basic-with-dependency-injection/src/server.ts:13:12)

Unable to resolve providers - Prisma integration

The following is part from a main.ts.

// main.ts
const { schema, context, resolvers } = AppModule;

const prismaBinding = new PrismaBinding({
    endpoint: PRISMA_ENDPOINT,
    secret: PRISMA_MANAGEMENT_API_SECRET,
    debug: NODE_ENV === 'development',
    fragmentReplacements: extractFragmentReplacements(resolvers),
  });

const server = new ApolloServer({
  schema,
  introspection: true,
  playground: true,
  context: async (networkRequest: Request) => {
      const ctx = await context(networkRequest);
      ctx.injector.provide<PrismaClient>({
        provide: PrismaClient,
        useValue: prismaClient,
        scope: ProviderScope.Application,
      });
      ctx.injector.provide<PrismaBinding>({
        provide: PrismaBinding,
        useValue: prismaBinding,
        scope: ProviderScope.Application,
      });
      return { ...ctx };
    },
});

And I'm trying to get it somewhere in my UserModule. But it says dependency not found.

import { Prisma as PrismaClient } from '@/lib/prisma/prisma-client';
import { QueryResolvers, UserResolvers } from '@/types';

export const Query: QueryResolvers.Resolvers = {
  user: (parent, args, ctx, info) => {
    console.log('?', ctx.injector.get(PrismaClient));
    return {
      id: '1',
      username: 'chanlito',
      email: '[email protected]',
      password: '',
      createdAt: new Date().toISOString(),
      updatedAt: new Date().toISOString(),
    };
  },
};

I don't know if this is even allowed or not.

info: GraphQLResolveInfo not given to resolver

A resolver within a GraphQLModule does not receive the value of info.

Query: {
        videos(parent, args: {}, context: Context, info: GraphQLResolveInfo) {
            return context.db.videos({
                where: {
                    isActive: false,
                    resource: { transcodingStatus: 'PENDING' },
                },
            })
        },
    },

Example receives a value of undefined unless given as a resolver outside of a module.

Cannot import .graphql files

Hello!

I have been trying to use TypeScript to import .graphql files, by using the method mentioned here, however, I consistently receive the error:

src/modules/auth/index.ts(2,27): error TS2307: Cannot find module './schema.graphql'.``

I have tried placing the typings.d.ts file within the same directory as the .graphql file, at the src level, at the project root. None have altered a single thing. It's as if TS isn't even seeing the .d.ts file.

Here is the tsconfig:

  "compilerOptions": {
    "lib": ["es2017", "esnext.asynciterable", "dom"],
    "target": "es2017",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "outDir": "dist",
    "typeRoots": ["node_modules/@types"],
    "paths": {
      "@lib/*": ["./lib/*"],
      "@models/*": ["./models/*"],
      "@modules/*": ["./modules/*"]
    },
    "baseUrl": "./src/",
    "allowSyntheticDefaultImports": true
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules"]
}

I have found this related issue, but despite trying all listed solutions, I have not been able to resolve the error.

Any help would be greatly appreciated.

[Feature request] Provide onResponse and onError hooks

Currently, there is a hook called onHook which is very useful. I believe it would be great to to extend this functionality by adding new hooks, like onResponse and onError or implement request middlewares.

Use case:

I would like to send errors to a error reporting tool, like Sentry. Currently, i need to use Apollo Server formatError, which does not come with the context of the request. To get the context, i need to add it as plugin and call the context directly. I'm not sure how this would work in insolation.

By using graphql-middleware, we can not only track the errors, but change the args, response, etc. Very similar to how resolver compositions work.

export const SentryMiddleware: MiddlewareFn = async ({ root, args, context, info }, next) => {
  try {
    const response = await next();

    if (response instanceof Error) {
      notifyError(response, context);
    }

    return response;
  } catch (error) {
    notifyError(error, context);

    throw error;
  }
}

Subscriptions?

I there any limitation for using graphql-modules with subscriptions?

[0.4.0] TypeError: Cannot use 'in' operator to search for 'subscribe' in ASC

works in 0.2.18 but fails on 0.3.0+

schema:

enum ConnectionOrderDirection {
ASC
DESC
}

TypeError: Cannot use 'in' operator to search for 'subscribe' in ASC
at _loop_2 (/Users/daniel/Code/OrangeLoops/phoenix-server/node_modules/@graphql-modules/core/dist/graphql-module.js:446:42)
at _loop_1 (/Users/daniel/Code/OrangeLoops/phoenix-server/node_modules/@graphql-modules/core/dist/graphql-module.js:477:21)
at GraphQLModule.addSessionInjectorToSelfResolversContext (/Users/daniel/Code/OrangeLoops/phoenix-server/node_modules/@graphql-modules/core/dist/graphql-module.js:483:13)
at GraphQLModule.buildSchemaAndInjector (/Users/daniel/Code/OrangeLoops/phoenix-server/node_modules/@graphql-modules/core/dist/graphql-module.js:659:30)
at GraphQLModule.get [as injector] (/Users/daniel/Code/OrangeLoops/phoenix-server/node_modules/@graphql-modules/core/dist/graphql-module.js:133:22)
at GraphQLModule.buildSchemaAndInjector (/Users/daniel/Code/OrangeLoops/phoenix-server/node_modules/@graphql-modules/core/dist/graphql-module.js:592:43)
at GraphQLModule.get [as schema] (/Users/daniel/Code/OrangeLoops/phoenix-server/node_modules/@graphql-modules/core/dist/graphql-module.js:117:22)

Is there a way to use graphql-shield with modules?

I tried to see if I could use graphql-shield via the middleware options field in graphql-modules, but that did not seem to work. The resolversComposition options seem like a good place to make it work as well, but graphql-shield is really set up to be used as middleware. Any tips on how to make it work? I can alway use the permissions at the top when I instantiate the server, but would rather the permissions be co-located with the resolvers in the module.

[Feature request] Better way to identify module

Error:
      GraphQL-Modules Error: Schema is not valid!
      - #Module #2268816439529191 doesn't have a valid schema!
      -- Unknown type "Customer".

Unknown type "Customer".

I have 10 modules in my app... which one is 2268816439529191?!

Make graphlql-modules compatible with SchemaLink

I'm using an alpha based on this PR #312
And I have exactly the same issue on the larger codebase as I have here in sandbox below.
https://codesandbox.io/s/92kxln66vy

I think SchemaLink is used in unit tests heavily when you develop a real ApolloServer.
But I'm using it to have GraphQL Server on Client.

Making it work properly will enable us at Revolut to use graphql-modules since we don't have a real server just yet.

Unable to resolve providers - typeorm typedi integration

How to use graphql-modules with typeorm and typedi ,now I got some problems .

GraphQL-Modules Error: Dependency Provider Not Found!
      - Provider #Repository couldn't be injected into Provider #Users
      -- Provider #Repository is not provided in #Module 591455874290757 scope!

      Possible solutions:
      - Make sure you have imported the module of Provider #Repository in the module of Provider 

[Bug] "type Subscription" overwrites query definition

Please look at the code below. I think this is a mistake clearly...

if (def.query) {
schemaRoot.query = def.query.toString();
}
if (def.mutation) {
schemaRoot.mutation = def.mutation.toString();
}
if (def.subscription) {
schemaRoot.query = def.subscription.toString();
}

It was merged between v0.2.9 and v0.2.10

d2db21b#diff-4d07e21e80acf6ceff3d3f867951b12bR44

image

Context silently ignores errors

I've spent a significant amount of time trying to find an error 500 which was emitted by my GraphQL-Modules back-end and surprised to discover that the context handler silently ignores errors. To overcome this problem, I have wrapped my context promise like so:

    context: (args: any) => {
      return Promise.resolve(context(args)).catch((e) => {
        console.error(e)
      })
    },

I suggest to make this behavior a default. Pretty sure it will save a lot of struggles and potential issues.

Remove logger package

It was part of the initial implementation, then we separated it, and now I think we can remove it.
We can expose an interface for logger so people can use their own loggers.

@ardatan

Links not distinguishable

Hey guys,
just wanted to let you know that links in the documentation aren't clearly distinguishable from normal text.
Even if you hover them there is no underline or anything which would indicate that it is a link.

Example on the first Site I read:
Example with undistinguishable link
»Separation of Concerns« is a link

Accessing module configuration from resolver

Currently there is some solid documentation around using dependency injection to access configuration in providers.

If one isn't using providers, how is configuration accessed from the resolver directly?

Providing non-graphql-modules context to apollo-server

Hi!

First off, I love the look of this project, it seems to go down a few similar paths as we do in production.

However we need to pass in custom objects in to Apollo Server's context due to our implementation and I can't see an obvious way to combine that with using the context provided by graphql-modules.
Is this something you have considered?

Cheers,

Fabian

Will there be Relay support?

In my current APIs I have a lot of Relay stuff like the Node interface and node field, plus connections et al.

I was wondering if you guys thought about it or if you have any tips to implement something like the node field, which gets any object in any module by id.

Querying schema internally?

Hi,
is it possible to query the generated schema internally, i.e. without network / graphql server?
Normally, it is possible to pass schema to graphql function and query against it.
See: graphql/graphql-js#1043 (comment)

When I try to do the same with graphql-modules, I get TypeError: Cannot read property 'moduleNameContextMap' of undefined.

Should this be doable somehow?

I am currently using @graphql-modules/core version 0.3.0-alpha.d74cc126.

Thanks!

How to deal with types?

All of the examples and docs use *.ts files but without any types for resolvers. So all of the benefits of TypeScript are lost, it's just a JS with decorators and easier DI.

There are a few graphql types generator, like graphql-code-generator and graphqlgen. Do you have any solution for generating types from schema (typedefs) split into modules?

contextBuilder property doesn't exist

There are a bunch of places showing the usage of contextBuilder but when I try to use it, it doesn't exist. Typescript only shows context property.

screen shot 2018-12-03 at 10 17 21 am

Dependency deprecation warning: @types/deepmerge (npm)

On registry https://registry.npmjs.org, the "latest" version (v2.2.0) of dependency @types/deepmerge has the following deprecation notice:

This is a stub types definition. deepmerge provides its own type definitions, so you do not need this installed.

Marking the latest version of an npm package as deprecated results in the entire package being considered deprecated, so contact the package author you think this is a mistake.

Please take the actions necessary to rename or substitute this deprecated package and commit to your base branch. If you wish to ignore this deprecation warning and continue using @types/deepmerge as-is, please add it to your ignoreDeps array in Renovate config before closing this issue, otherwise another issue will be recreated the next time Renovate runs.

Affected package file(s): packages/epoxy/package.json

Would you like to disable Renovate's deprecation warning issues? Add the following to your config:

"suppressNotifications": ["deprecationWarningIssues"]

Compiling with tsc gives error when running dist with node

Maybe I do something wrong :) but when i build my typescript project i got an error when trying to run the distribution. As the example said im using sonar and epoxy to load their files. The error is not breaking the application but i think it should not try to include this type of file

Example of one module:

import { GraphQLModule } from '@graphql-modules/core';
import { loadResolversFiles, loadSchemaFiles } from '@graphql-modules/sonar';
import { mergeGraphQLSchemas, mergeResolvers } from '@graphql-modules/epoxy';

import { Users } from './providers/users';

export const userModule = new GraphQLModule({
  name: 'user',
  providers: [Users],
  resolvers: mergeResolvers(loadResolversFiles(__dirname + '/resolvers/')),
  typeDefs: mergeGraphQLSchemas(loadSchemaFiles(__dirname + '/schema/')),
});

Now in the distribution the resolver directory now also contains some *.d.ts files which should not be included. Error it gives when trying to run the dist with node:

Unable to load resolver file: .../dist/modules/user/resolvers/query.d.ts, error: SyntaxError: Unexpected token import

[Question] Using libraries such as join-monster, which rely on mutating schema instance

Hi again.

I've recently discovered a few GraphQL libraries that work by decorating / mutating the schema (GraphQLSchema) instance, and depend on those changes being persisted and not overwritten, such that those decorations can be accessed in resolvers with the resolverInfo argument (fourth argument). For example, join-monster requires adding custom properties to GraphQLObjectType constructors in order to be configured. When using Apollo, this can be achieved using an adapter, such as join-monster-graphql-tools-adapter, which works by decorating / mutating the schema based on a custom object you pass to it.

As far as I can tell, I cannot rely on mutating the schema instance in such a way when using GraphQL Modules, as the schema are built using a factory method, which is called at strategic points in the control flow.

This has lead me to abandon the idea of being able to use such libraries with GraphQL Modules, viewing them as being idiomatically incompatible with one another. Is this an accurate conclusion, or have I missed something? Perhaps the solution could be as simple as formalising an interface for mutating / transforming a schema at a strategic point before the resolvers get called?

Cheers.

Modules are a pain

So I split my IDL schema in multiple files:

  • commons.graphql
  • customer.graphql
  • catalog.graphql
  • order.graphql

of course, there is cross dependency between these files.

Just pointing out that having to manually add # import TaxExemptionEnum from '../commons/commons.graphql'
is REALLY painful. Any idea how to solve this?

Importing providers with configurations without merging Query schemas

Suppose you have a simple module with a provider that relies on an injected configuration:

// ProviderA.ts
import { Injectable, Inject } from "@graphql-modules/di"
import { ModuleConfig } from '@graphql-modules/core'
import "reflect-metadata"

@Injectable()
export class ProviderA {
    constructor(@Inject(ModuleConfig('module-a')) private config: Config) {}

    withIds(ids: string[]): String[] {
        return [];
    }
}
// ModuleA.ts
import { GraphQLModule, ModuleContext } from '@graphql-modules/core'
import { ProviderA } from './ProviderA'
import gql from 'graphql-tag'

export const ModuleA = new GraphQLModule<ModuleAConfig>({
    name: 'module-a',
    providers: () => [ProviderA],
    typeDefs: gql`
        type Query {
            people:(ids: [ID]!): [String]
        }
    `,
    resolvers: {
        Query: {
            people: (_, {ids}, {injector}: ModuleContext) => injector.get(ProviderA).withIds(ids)
        }
    }
})

And you try to create a higher order module that utilizes ProviderA:

// ModuleB.ts
import { GraphQLModule } from '@graphql-modules/core';
import { ModuleA, ModuleAConfig } from './ModuleA'

export interface ModuleBConfig {
    moduleA: ModuleAConfig
}

export const ModuleB = new GraphQLModule<ModuleBConfig>({
    name: 'module-b',
    imports: ({config}) => [ModuleA.forRoot(config.moduleA)],
    providers: () => [ProviderA],
    typeDefs: gql`
        type Query {
            composed(ids: [ID]!): [String]
        }
    `,
    resolvers: {
        Query: {
            composed: (_, {ids}, {injector}: ModuleContext) => {
                return injector.get(ProviderA).withIds(ids).map(
                    // transform...
                )
            }
        }
    }
})

With the above setup, composed and people will both be exposed as queries. Is there a way to only import the providers and pass them configuration?

TypeError: Reflect.hasMetadata is not a function

Using 0.2.0 and examples within documentation, I'm receiving TypeError: Reflect.hasMetadata is not a function from @graphql-modules/core/dist/di/index.js:208:22

I'm not using any dependency injection, just basic example.

Accessing `GraphQLModule.schema` from within `resolversComposition` function

Hello!

I am trying to implement an authentication guard, using resolvers composition, and GraphQL @directives. I have observed that resolversComposition can be provided as a function that accepts GraphQLModule.

I was hoping to be able to access GraphQLModule.schema, in order to access the GraphQLSchema, which I'd need to do in order to map logic functions to fields with directives.

However, when I attempt to access GraphQLModule.schema, I receive the following error:

RangeError: Maximum call stack size exceeded
    at new Injector (/Users/jackchapple/node-projects/telco-api/node_modules/@graphql-modules/core/src/di/injector.ts:9:21)
    at GraphQLModule.buildSchemaAndInjector (/Users/jackchapple/node-projects/telco-api/node_modules/@graphql-modules/core/src/graphql-module.ts:395:22)
    at GraphQLModule.get [as schema] (/Users/jackchapple/node-projects/telco-api/node_modules/@graphql-modules/core/src/graphql-module.ts:160:12)
    at exports.resolversComposition (/Users/jackchapple/node-projects/telco-api/src/modules/auth/resolvers-composition.ts:13:56)
    at GraphQLModule.get [as selfResolversComposition] (/Users/jackchapple/node-projects/telco-api/node_modules/@graphql-modules/core/src/graphql-module.ts:319:33)
    at GraphQLModule.buildSchemaAndInjector (/Users/jackchapple/node-projects/telco-api/node_modules/@graphql-modules/core/src/graphql-module.ts:411:80)
    at GraphQLModule.get [as schema] (/Users/jackchapple/node-projects/telco-api/node_modules/@graphql-modules/core/src/graphql-module.ts:160:12)
    at exports.resolversComposition (/Users/jackchapple/node-projects/telco-api/src/modules/auth/resolvers-composition.ts:13:56)
    at GraphQLModule.get [as selfResolversComposition] (/Users/jackchapple/node-projects/telco-api/node_modules/@graphql-modules/core/src/graphql-module.ts:319:33)
    at GraphQLModule.buildSchemaAndInjector (/Users/jackchapple/node-projects/telco-api/node_modules/@graphql-modules/core/src/graphql-module.ts:411:80)
    at GraphQLModule.get [as schema] (/Users/jackchapple/node-projects/telco-api/node_modules/@graphql-modules/core/src/graphql-module.ts:160:12)
    at exports.resolversComposition (/Users/jackchapple/node-projects/telco-api/src/modules/auth/resolvers-composition.ts:13:56)
    at GraphQLModule.get [as selfResolversComposition] (/Users/jackchapple/node-projects/telco-api/node_modules/@graphql-modules/core/src/graphql-module.ts:319:33)
    at GraphQLModule.buildSchemaAndInjector (/Users/jackchapple/node-projects/telco-api/node_modules/@graphql-modules/core/src/graphql-module.ts:411:80)
    at GraphQLModule.get [as schema] (/Users/jackchapple/node-projects/telco-api/node_modules/@graphql-modules/core/src/graphql-module.ts:160:12)
    at exports.resolversComposition (/Users/jackchapple/node-projects/telco-api/src/modules/auth/resolvers-composition.ts:13:56)
printErrorAndExit @ VM98 source-map-support.js:444
process.emit @ VM98 source-map-support.js:457
process._fatalException @ VM10 node.js:628

Here's my resolvers-composition.ts:

import { GraphQLModule } from '@graphql-modules/core';
// import { GraphQLSchema } from 'graphql';
import { authenticated } from './authenticated-guard';
import { validateRole } from './validate-role';

const DIRECTIVE_TO_GUARD = {
  auth: () => authenticated,
  protect: ({ role }) => validateRole(role),
};

export const resolversComposition = (module: GraphQLModule) => {
  console.log('resolversComposition', { schema: module.schema }); // throws
}

Am I doing something incorrectly? Many thanks in advance.

Extending types is not working

Hello,

I was reading the following article https://medium.com/the-guild/graphql-modules-feature-based-graphql-modules-at-scale-2d7b2b0da6da

And I tried to reproduce the user-chat example, to see how extending types work.
I forked the repo, and I added in examples/basic, a chat and a user module:

https://github.com/eelayoubi/graphql-modules/blob/feature/test-extend-types/examples/basic/src/app/user.module.ts

https://github.com/eelayoubi/graphql-modules/blob/feature/test-extend-types/examples/basic/src/app/chat.module.ts

in app.module: I imported them, the way you did, so that the chat module can extend the User type.

https://github.com/eelayoubi/graphql-modules/blob/feature/test-extend-types/examples/basic/src/app/app.module.ts

But I noticed that it does not extend it , it overrides it, for some reason. You can see that in the screenshot I took from the playground schema:
screen shot 2018-12-20 at 15 33 36

Is there an extra config that we need to add to make it extends and not override the User type?

Thanks a lot for your help .

About lucasconstantino/graphql-modules

Hey, you!

Thank god someone built a better solution for GraphQL modularization. I have had my approach on it a couple of years ago, published as (guess what?) graphql-modules.

I'm here to charge you for copy-right violations

No, seriouly now: I didn't take my project forward, but there are still people reaching there and using a code-base which is more then 2 years old... thus why I'm here to see if you guys know what can we do to properly deprecate that project and point everything here. Also, I've seen you already got a nice @graphql-modules package namespace, but if it makes any difference I would be glad to make graphql-modules it available for you.

Cheers, thanks for the nice and needed open-source ;)

Use of provider vs. RESTDataSource

I would love to see some examples in the documentation of when to use a provider vs. RESTDataSource

Do they work together? It seems like a provider would be re-implementing a lot of methods that already exist in a RESTDataSource. Also I'm guessing any RESTDataSources would go into the contextBuilder?

epoxy does not emit directives

Reproduction #54

It causes an issue in one of our client's app.
When we generate there types via graphql-code-generator with typescript-mongodb template all the interfaces with a suffix DBObject are not generated.

I looked and before using @graphql-modules/epoxy, it works fine.

How to solve n+1 problem with graphql-modules?

I am just getting started with graphql-modules and would like to know if (and if yes, how) the n+1 problem is solved. Also, it would be very helpful to add a section dedicated to it in the docs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.