Closed GQAdonis closed 5 years ago
Some extra information:
The code in the repo for this article (https://medium.com/@mattchewone/graphql-with-feathersjs-4cc67e785bd) works. However, when I update it using "feathers-plus generate all", that code stops working.
Something seems broken in the current release of the feathers-plus cli....
What are the contents of src/services/graphql/graphql.schema.?s of your project?
Thanks @eddyystop! Here are the contents of the graphql.schema.js file:
// Define the combined GraphQL schema. (Can be re-generated.)
// !code: imports // !end
// !code: init // !end
let moduleExports = `
type Role {
id: ID
name: String!
}
type User {
id: ID
email: String!
firstName: String!
lastName: String!
password: String
roleId: ID!
}
type Query {
getRole(key: JSON, query: JSON, params: JSON): Role
findRole(query: JSON, params: JSON): [Role]!
getUser(key: JSON, query: JSON, params: JSON): User
findUser(query: JSON, params: JSON): [User]!
}
`;
// !code: exports // !end
module.exports = moduleExports;
// !code: funcs // !end
// !code: end // !end
The schema looks fine. How exactly did you make the GraphQL call? I mean was it via REST or WebSockets and what was the code making the call?
The format for calling the graphql service within Feathers is graphql.find({ query: { query: '{ getRole(...) {...} }' } })
.
Don't forget to include the second query
in a REST call.
Thanks again for your quick response. I am not using feathers-client to make the GraphQL call. I was using GraphIQL (the graphical Mac app) for testing. I also used CURL manually with both GET and POST requests.
As I said earlier the code base for the sample article at https://github.com/Mattchewone/feathers-graphql-demo works, but it was generated with an older version of the CLI. When upgrading this code base to the current libraries using generate all
, it stops working.
Make sense?
Others are making GraphQL calls without issues, so let not sidetrack ourselves with Matt's repo.
I have no experience with the Mac graphql app, so I don't know if it automatically inserts a query
in front of the query string you are using, like Graphiql does. Please try a string without the shorthand syntax.
I believe we can close this issue as no reply has been received in 28 days.
Steps to reproduce
I hope this is the place to ask this question, but I followed the instructions in your tutorial for feathers-plus to the letter. I am using a MongoDB instance, configured authentication (that works), with ONLY Users and Roles services in the simplest possible configuration.
I ran all the appropriate generation scripts at the appropriate times.
Expected behavior
What I expected was to be able to run this simple query from within GraphIQL:
{ getRole(key:"5c4f198068b713cd0c08b2b9") { name } }
and receive the appropriate response (after inserting roles into my MongoDB database).
Actual behavior
Instead, I get the following error:
info: Feathers application started on http://localhost:3030 error: BadRequest: Schema must be an instance of GraphQLSchema. Also ensure that there are not multiple versions of GraphQL installed in your node_modules directory. at new BadRequest (/Users/gqadonis/Projects/TribeHealth/sprint1/air-server/node_modules/@feathers-plus/graphql/node_modules/@feathersjs/errors/lib/index.js:81:17) at graphql.catch.err (/Users/gqadonis/Projects/TribeHealth/sprint1/air-server/node_modules/@feathers-plus/graphql/lib/index.js:79:17) at process._tickCallback (internal/process/next_tick.js:68:7) error: BadRequest: Schema must be an instance of GraphQLSchema. Also ensure that there are not multiple versions of GraphQL installed in your node_modules directory. at new BadRequest (/Users/gqadonis/Projects/TribeHealth/sprint1/air-server/node_modules/@feathers-plus/graphql/node_modules/@feathersjs/errors/lib/index.js:81:17) at graphql.catch.err (/Users/gqadonis/Projects/TribeHealth/sprint1/air-server/node_modules/@feathers-plus/graphql/lib/index.js:79:17) at process._tickCallback (internal/process/next_tick.js:68:7) error: BadRequest: Schema must be an instance of GraphQLSchema. Also ensure that there are not multiple versions of GraphQL installed in your node_modules directory. at new BadRequest (/Users/gqadonis/Projects/TribeHealth/sprint1/air-server/node_modules/@feathers-plus/graphql/node_modules/@feathersjs/errors/lib/index.js:81:17) at graphql.catch.err (/Users/gqadonis/Projects/TribeHealth/sprint1/air-server/node_modules/@feathers-plus/graphql/lib/index.js:79:17) at process._tickCallback (internal/process/next_tick.js:68:7)
System configuration
I am on a MacBook Pro using Node.js version 10.15.
Module versions (especially the part that's not working):
NodeJS version:
Operating System:
Browser Version:
React Native Version:
Module Loader: