EasyGraphQL / easygraphql-tester

Test GraphQL queries, mutations and schemas on an easy way! 🚀
https://easygraphql.com/docs/easygraphql-tester/overview
MIT License
313 stars 34 forks source link

Issue with extend type Query #108

Closed jeevanpillay0000 closed 5 years ago

jeevanpillay0000 commented 5 years ago

Hi,

So I just started using easygraphql-tester, however, I ran into a problem.

My applications is structure by using stitching to achieve modularisation.

Therefore, my schema.js, looks something like this: ` const { gql } = require("apollo-server");

const user = require("./models/user/user.schema");

const root = gql` type Query { root: String }

type Mutation { root: String } `;

module.exports = [root, user];

`

User.js `const { gql } = require("apollo-server"); const user = gql' extend type Query { getCurrentUser: User } extend type Mutation { signupUser(username: String!, email: String!, password: String!): AuthToken signinUser(username: String!, password: String!): AuthToken } type AuthToken { token: String! } type User { _id: ID username: String! password: String! email: String! joinDate: String tokens: [Token] } ';

module.exports = user;`

Issue is that, when I try to build like this const typeDefs = require('./schema.js'); let tester = new EasyGraphQLTester(typeDefs);

This returns an error saying

TypeError: Must provide Source. Received: { kind: "Document", definitions: [[Object], [Object]], loc: [Object] }

I think the issue is with the syntax extend type Query.

Is there a workaround?

estrada9166 commented 5 years ago

You can update the version of easygraphql-tester for the latest one, and then remove extend from the schemas. It's using merge-graphql-schemas under the hood and it works without the extend.

Let me know if it works for you!

estrada9166 commented 5 years ago

@lpfloyd I'm going to close this issue, if it's needed we can open again.