Skip to content
New issue

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

connector[connectorName] is not a function #22

Closed
lacker opened this issue Jun 7, 2016 · 8 comments
Closed

connector[connectorName] is not a function #22

lacker opened this issue Jun 7, 2016 · 8 comments

Comments

@lacker
Copy link

lacker commented Jun 7, 2016

I'm getting a weird error in initial apollo server setup which seems to be swallowed by the GraphQL layer and it is frustrating because I don't see how I can track it down. I thought all I was doing was roughly copying the example while renaming things, but I must have miscopied something somewhere.

{ "data": { "getUsers": null }, "errors": [ { "message": "connectors[connectorName] is not a function", "locations": [ { "line": 2, "column": 3 } ] } ] }

Line 2, column 3 of what? It is definitely not within my own code. That error is not too helpful. What should I be doing to track this down?

@helfer
Copy link
Contributor

helfer commented Jun 7, 2016

@lacker Yeah, GraphQL error messages aren't easy to debug. The line and column numbers actually correspond to the query. So whatever field is on the second line of your query has a resolve function which throws that error. From the looks of it the error is from some code that tries to initialize connectors. Are you passing any connectors to Apollo Server, and are they constructors? If not, that might be the problem. If that doesn't help you solve it, you can pass the following function as the formatError argument to Apollo Server (or a variation thereof which gives you a stack trace or whatever other information you need about the error):

function printError(err){
  if(err.originalError){
    console.log(err.originalError);
  } else {
    console.log(err);
  }
  return err;
}

PS: We have a PR that should improve error messages in GraphQL. We hope it will make it into GraphQL-JS soon.

@lacker
Copy link
Author

lacker commented Jun 7, 2016

Mmmm ok I found it. Yeah I really just want the stack trace when something goes wrong, at least when I am running in development mode. That is e.g. how Rails does it. Even if it's just printed out by the server.

@lacker lacker closed this as completed Jun 7, 2016
@helfer
Copy link
Contributor

helfer commented Jun 7, 2016

Agreed. We should make this the default behavior for Apollo Server when no formatError function is provided.

@wzalazar
Copy link

Hi, I have the same error, could you explain how to fix them?

@stubailo
Copy link
Contributor

stubailo commented Aug 29, 2016

BTW there's an issue open for the stack trace thing if anyone wants to look at it: #111

@wzalazar
Copy link

Thank's you.

I'm new in Apollo, so I try apollo server in Meteor application and my configuration was

const executableSchema = makeExecutableSchema({
  typeDefs: Schema,
  resolvers: Resolvers,
  connectors: Connectors,
});

like show the documentation, and I think the connector was my Meteor collection, My assumption was wrong.
I remove connectors of my configuration and It's works.

Now looks this way

const executableSchema = makeExecutableSchema({
  typeDefs: Schema,
  resolvers: Resolvers,
});

@helfer
Copy link
Contributor

helfer commented Aug 30, 2016

@wzalazar for connectors, are you passing in an object with string keys, eg. { 'collection': collection }. That's the intended usage.

@wzalazar
Copy link

wzalazar commented Aug 30, 2016

If anyone need an example, Meteor + Apollo, I created an repository https://github.com/wzalazar/graphql-meteor

evans pushed a commit that referenced this issue Jul 3, 2018
* Initial commit

* Add .npmignore to avoid ignoring lib when publishing

* 0.0.2

* Update graphql-extensions dependency to 0.0.2

* 0.0.3

* Reorganize code and add tests

* 0.0.4

* Add tests and reorganize code

* 0.0.5

* Update dependency to graphql-extensions 0.0.4

* 0.0.6

* Update graphql-extensions dependency and downgrade TS target

* 0.0.7

* Update README

* Update README

* Update README

* Update README

* Add import instructions for TypeScript to README (#7)

* Add cache hints when the directive is defined on interfaces (#10)

* Increase version range for `graphql` peerDependency. (#12)

* 0.0.8

* Update dependencies

* 0.0.9

* [apollo-bot] Update the Issue/PR Templates with auto label (#13)

* [apollo-bot] Update the Templates with docs label (#15)

* Add cache hints to info.cacheControl (#16)

This exposes the `cacheControl` hints on the schema, to the resolvers at runtime.

* Update `graphql` peer dependency range to allow 0.13.x.

* dev: Update TypeScript to latest version, v2.7.2.

* dev: Update jest & dependencies to latest versions.

* dev: Update type definitions for `graphql`, `node` and `jest`.

* dev: Update `graphql` to latest version, v0.13.2.

* 0.0.10

* Add defaultMaxAge option

This is an easy way to quickly say "I want everything in my schema to be cached
for 5 seconds". You can override it with specific maxAges on specific fields or
types.

An upcoming release of apollo-server-* will allow you to specify options to
cacheControl.

* Add CircleCI config

* Add partial CHANGELOG

* 0.1.0

* Honor overwrite default maxAge with maxAge=0 (Fixes #22) (#23)

* 0.1.1

* Allow default caching to apply to interfaces

* remove unused files

* update versions and use a-s style config

* run prettier

* fix tests and typing
trevor-scheer pushed a commit that referenced this issue May 6, 2020
In the same spirit as #2344,
this should hopefully _gently_ help us not use types which aren't available
in all of the versions of Node.js which we currently target.
trevor-scheer pushed a commit that referenced this issue May 14, 2020
In the same spirit as #2344,
this should hopefully _gently_ help us not use types which aren't available
in all of the versions of Node.js which we currently target.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants