Comments (6)
I'm not that familiar with NestJS, but I believe if you provide both typePaths
and typeDefs
, the resulting type definitions should be merged together. So you should be able to do:
import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { schemaDirectives, typeDefs } from 'sqlmancer';
import { UserModule } from './user/user.module';
@Module({
imports: [
UserModule,
GraphQLModule.forRoot({
typePaths: [`${__dirname}/**/*.graphql`],
schemaDirectives,
typeDefs,
}),
],
})
export class AppModule {}
from sqlmancer.
Hi @unlight Thanks for the bug report.
The directives included in schemaDirectives
will not include all possible directives -- only the ones that actually transform the schema as opposed to just conveying some information about your database. So what you're seeing in the console is accurate.
The errors you're seeing indicates a possible issue with the SDL type definitions for the directives. If you're not using makeSqlmancerSchema
, then the type definitions have to be added manually as shown here
import { typeDefs, schemaDirectives } from 'sqlmancer';
import { ApolloServer } from 'apollo-server';
const apollo = new ApolloServer({
typeDefs: [yourTypeDefs, typeDefs],
resolvers: yourResolvers,
schemaDirectives: { ...yourSchemaDirectives, ...schemaDirectives },
});
Can you share a more complete example of how you're creating your schema, including any imports?
from sqlmancer.
I'm using NestJS with schema first approach (I tried code first, but seems it's not yet supported).
Main file looks like
import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { schemaDirectives } from 'sqlmancer';
import { UserModule } from './user/user.module';
@Module({
imports: [
UserModule,
GraphQLModule.forRoot({
typePaths: [`${__dirname}/**/*.graphql`],
schemaDirectives: {
...schemaDirectives,
},
}),
],
})
export class AppModule {}
So, there is no typeDefs
or resolvers
mentions in NestJS tutorials, however GraphQLModule.forRoot
can accept them according to signature.
typeDefs
, resolvers
is generated somewhere under the hood of NestJs from decorated classes/methods.
from sqlmancer.
Thank you, that's worked.
But NestJS's GraphQLModule typeDefs
expects string
typeDefs: typeDefs.loc!.source.body,
from sqlmancer.
@unlight As a temporary workaround, you can do
import { print } from 'graphql'
...
typeDefs: print(typeDefs),
I can export the typeDefs as a string in the next release.
from sqlmancer.
It would also be worthwhile to document NestJS integration alongside any other commonly-used libraries
from sqlmancer.
Related Issues (20)
- graphql-toolkit is now deprecated in favor of graphql-tools
- The Node interface and globally unique IDs HOT 1
- add sybase support
- [RFC] Changes to the existing API and workflow HOT 12
- Issue when using esModuleInterop option HOT 3
- Trouble adding `@paginate` directives HOT 3
- Allow passing a schema directly to createSqlmancerClient
- Hitting some issues with one to many relations and retreiving specific fields HOT 2
- Ability to specify default and maximum limit values
- Customizable argument and input field names
- Suggestion: Expose join API on Builder Class HOT 3
- Depend on not passing field to the resolver unless in the query HOT 3
- Add ability to mock database results
- tion
- CTE in WHERE clause is empty HOT 1
- Join by multiple fields HOT 1
- https://sqlmancer.netlify.app/ is dead
- Allow composite primary keys HOT 1
- Is there a Roadmap? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlmancer.