We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I am stucked into bi-directional schema mapping. posts <-> authors.
Following are the two schema we are using.
posts.js // here we are requiring authors.js class Post {} const { nodeInterface, nodeField } = nodeDefinitions( globalId => { const { type, id } = fromGlobalId(globalId); // return based on the id return DataSource['posts'][0]; }, obj => { console.log(" : PostType : ", PostType); // type to be return return Post; } ); const PostType = new GraphQLObjectType({ "name": "PostType", "description": "Posts type and it's relevant fields", "fields": () => ({ "id": globalIdField('Post'), "title": { "type": GraphQLString }, "body": { "type": GraphQLString }, "author": { "type": AuthorsConnection, "resolve": (parent, argument, root, currentSdl) => { console.log("v1, v2, v3, v4 :", parent); if (parent.author) return connectionFromArray(DataSource['authors'], {}) return []; } } }), isTypeOf: Post, interfaces: [nodeInterface] }); const { connectionType: PostsConnection, edgeType: GQLPostEdge } = connectionDefinitions({ name: "Post", nodeType: PostType }); module.exports = exports = { PostType, PostsConnection, schema: { post: nodeField, posts: { type: PostsConnection, resolve: (root, v2, v3) => { return connectionFromArray(DataSource['posts'], {}); } } } };
authors.js // here we have required posts.js const { PostType, PostsConnection } = require('./posts'); class Author {} const { nodeInterface, nodeField } = nodeDefinitions( globalId => { const { type, id } = fromGlobalId(globalId); // return based on the id return DataSource['authors'][0]; }, obj => { console.log(" : Authorype : ", Authorype); // type to be return return Author; } ); const AuthorType = new GraphQLObjectType({ "name": "AuthorType", "description": "Author type and it's relevant fields", "fields": () => ({ "id": globalIdField('Author'), "firstName": { "type": GraphQLString }, "lastName": { "type": GraphQLString }, authorPosts: { type: PostsConnection, resolve: (parent, args, root, context) => { return connectionFromArray(DataSource['posts'], {}); } } }), isTypeOf: null, interfaces: [nodeInterface] }); const { connectionType: AuthorsConnection, edgeType: GQLAuthorEdge } = connectionDefinitions({ name: "Author", nodeType: AuthorType }); module.exports = exports = { AuthorType, AuthorsConnection, schema: { author: nodeField, authors: { type: AuthorsConnection, resolve: (root, v2, v3) => { return connectionFromArray(DataSource['authors'], {}); } } } };
Once I merge above schema for GraphQL I am getting following error.
Error: Schema must contain unique named types but contains multiple types named "Node".
I tried to debugged this issue, following is I observed following.
Please let me know what is issue here, is it relevant to nodeDefinitions function?
nodeDefinitions
The text was updated successfully, but these errors were encountered:
You should share the Node interface between schemas, e.g. extract it into a separate file.
Node
Sorry, something went wrong.
No branches or pull requests
I am stucked into bi-directional schema mapping. posts <-> authors.
Following are the two schema we are using.
Once I merge above schema for GraphQL I am getting following error.
Error: Schema must contain unique named types but contains multiple types named "Node".
I tried to debugged this issue, following is I observed following.
Please let me know what is issue here, is it relevant to
nodeDefinitions
function?The text was updated successfully, but these errors were encountered: