graphql-modules | Enterprise Grade Tooling For Your GraphQL Server | GraphQL library
kandi X-RAY | graphql-modules Summary
kandi X-RAY | graphql-modules Summary
GraphQL Modules is a toolset of libraries and guidelines dedicated to create reusable, maintainable, testable and extendable modules out of your GraphQL server.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of graphql-modules
graphql-modules Key Features
graphql-modules Examples and Code Snippets
Community Discussions
Trending Discussions on graphql-modules
QUESTION
I need help with custom directives when using graphql-modules library. Have no idea where to place my custom directives so it is combined with overall schema
...ANSWER
Answered 2021-Apr-24 at 11:07I would like to post answer from Discord community, from user Maapteh.
here it the quote from him
in our app with old version we had everything in common module. We kept that approach partly when using the latest version of modules. See some parts of our codebase:
import { ApolloServer, SchemaDirectiveVisitor } from 'apollo-server-express';
const schema = AppModule.createSchemaForApollo();
SchemaDirectiveVisitor.visitSchemaDirectives(schema, { isMember: IsMemberDirective, deprecated: isDeprecated, ...SNIP... });
as you can see we create the schema we pass eventually to the apollo server (example using apollo). We add our generic directives like so. The schema for them is in our common module. Read further...
For common scalars we added a common module. With their schema (so in schema directory we also have the directives schemas) and their resolver.
const typeDefsArray = loadFilesSync(
${__dirname}/schema/*.graphql
, { useRequire: true, }); const typeDefs = mergeTypeDefs(typeDefsArray, { useSchemaDefinition: false });const resolverFunctions = { ImageUrl: ImageUrlType, PageSize: PageSizeType, Date: DateResolver, ...SNIP... };
export const CommonModule = createModule({ id: 'common', typeDefs: typeDefs, resolvers: resolverFunctions, });
hope it helps you
https://discord.com/channels/625400653321076807/631489837416841253/832595211166548049
QUESTION
I'm not entirely sure about the purpose / action of __resolveType
function on an interface / union, but I suppose it's adding a __typename
field with the resolved type. However, I cannot seem to get this working with graphql-modules
. Here as subset, but sufficient subset of my schema.
ANSWER
Answered 2020-Apr-14 at 07:23I'm having the same issue, can confirm that it appears __resolveType is never called when using graphql-modules. I'm going to raise an issue in the repo and reference this SO. Will post back any answer I get.
It has already been reported in the repo issues and the fix was to pass the toplevel module schema to apollo-server, not as modules
QUESTION
I am new to graphQL, Apollo etc. Soon I will be working on a low-cost app with 3 (rest-api) datasources and only 1 consumer to create (mainly) a User Type. It's planned to use serverless functions as hosting. I've been reading on schema stitching, federation and modules, but can't find a good answer on why I should use Apollo federation in this small project. As I understand it, you need multiple apollo-servers and will have a higher deploy/serverless cost because of it compared to a monolithic Apollo-server.
A simplified example:
Server 1:
...ANSWER
Answered 2020-Apr-09 at 00:59If you just have a single User schema, its not a good idea to use apollo federation. Single Apollo server would suffice. You can have a single server talking to multiple data sources. Apollo federation is basically a new version of stitching. (Stitching is deprecated) Both schema stitching and Apollo federation are for micro services.
For an example, if you were building an e-commerce backend. You could have a server working on User type related queries and mutations(login, signup, user info etc.). You would have other services for order, products, stocks etc.
In general, one domain(schema) per service.
About extending types, the example you have shown is not ideal. lastname and email should probably be declared in the user service.
You would extend User type in one of the following scenarios:
- If you are referencing User type in another schema, for example
QUESTION
When implementing a GraphQL solution it is often advantageous to modularize aspects of the graph to simplify the understanding, implementation, and testing of the complete graph. Apollo, a popular GraphQL solution vender, provides Apollo Federation as a solution to this problem, deprecating "stitching" solutions. Other solutions, such as GraphQL Modules, implement this sort of behavior on a local server level. GraphQL Modules even integrates with Apollo Federation, and they are not necessarily mutually exclusive.
It would be really helpful to have some guidelines that indicate why you would need to federate your GraphQL implementation over multiple servers. It adds a lot of complexity. At what point does Apollo Federation make sense over a local module solution like GraphQL Modules. Why would you consider utilizing both?
...ANSWER
Answered 2019-Dec-16 at 21:19Both of them also allow to divide a GraphQL schema into different smaller schemas and then combine them after that. But one of the main differences is that GraphQL Module only works in the single server while Apollo Federation can work across different servers.
So , suppose you divide a schema into 3 modules (User,Product and Review) as follows :
GraphQL Module only allows all modules are implemented at the same server . It provides a opinionated ways to guide you separate each modules configuration such as its schema and resolver into their own code packages only.
On the other hand , Apollo Federation allows these 3 modules to be implemented on separates servers/microservices and allow you to combine them as a single GraphQL server declaratively.
QUESTION
I am trying to $push
an Object
into a nested array, however it doesn't seem to be working. I am not sure what I am doing wrong.
My database is like this:
...ANSWER
Answered 2018-May-21 at 10:49What you missed in your attempts is that arrayFilters
entries do not "autocast" like other properties in mongoose operations based on what value the "schema" has. This is because there is nothing there which actually ties the condition to a specific detail in the defined schema, or at least as far as the current mongoose release processes it.
Therefore if you match to an _id
within arrayFilters
, you need to actually "cast" the ObjectId
value yourself where the source comes from a "string":
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install graphql-modules
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page