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

Float cannot represent non numeric value: {} #90

Open
smeijer opened this issue Sep 24, 2018 · 7 comments
Open

Float cannot represent non numeric value: {} #90

smeijer opened this issue Sep 24, 2018 · 7 comments

Comments

@smeijer
Copy link

smeijer commented Sep 24, 2018

I've upgraded the apollo and graphql packages to it's latests versions; and thereby broke this package login method.

message: "Float cannot represent non numeric value: {}"
path: ["loginWithPassword", "tokenExpires"]
0: "loginWithPassword"
1: "tokenExpires"

Changed dependencies since it was working:

apollo-server-express:  1.3.6  >  2.1.0
graphql:                0.12.x > 14.0.2
graphql-tag:            1.0.x  >  2.9.2
graphql-tools:          3.0.4  >  4.0.0

meteor-apollo-accounts: 2.0.3   // unchanged

Meteor:

Meteor 1.7.0.3

accounts-password              1.5.1
apollo                         3.0.0
nicolaslopezj:apollo-accounts  3.2.2

@ujwal-setlur
Copy link

Have the same issue

@ujwal-setlur
Copy link

ujwal-setlur commented Sep 30, 2018

The following patch fixes it:

diff --git a/src/Auth.js b/src/Auth.js
index ff3825e..0ee8c54 100644
--- a/src/Auth.js
+++ b/src/Auth.js
@@ -7,7 +7,7 @@ type LoginMethodResponse {
   # Token of the connection
   token: String!
   # Expiration date for the token
-  tokenExpires: Float!
+  tokenExpires: String!
   # The logged in user
   user: User
 }

Seems to indicate that whatever Meteor is sending for tokenExpires to graphQL is a Date, and earlier it could parse it into a float, but not anymore. Guess graphql tightened it's parser.

@smeijer
Copy link
Author

smeijer commented Sep 30, 2018

A patch would be nice highly needed, but I guess it means that you lose earlier GraphQL versions?

@ujwal-setlur
Copy link

I am not sure, I think earlier graphql packages will also parse it as a String when the type is changed here. Remember, meteor has not changed here.

@joncursi
Copy link

How do you apply this patch in a production environment? Has anyone created a fork that we can use?

@ujwal-setlur
Copy link

ujwal-setlur commented Oct 20, 2018

I have a fork. it's meant to work with cultofcoders:apollo, but might work other apollo environments.

meteor add ujwal:apollo-accounts

@callmephilip
Copy link

callmephilip commented Feb 18, 2019

Managed to patch this as follows:

import { ApolloServer } from 'apollo-server-express';
import { loadSchema, getSchema } from 'graphql-loader';
import { makeExecutableSchema } from 'graphql-tools';
import { initAccounts } from 'meteor/nicolaslopezj:apollo-accounts';

initAccounts({
  loginWithFacebook: false,
  loginWithGoogle: false,
  loginWithLinkedIn: false,
  loginWithPassword: true,
});

// RE: https://github.com/orionsoft/meteor-apollo-accounts/issues/90
const schema = getSchema();
schema.typeDefs = schema.typeDefs.replace('tokenExpires: Float!', 'tokenExpires: String!');

/* ... */

EDIT:

looks like tokenExpires returns "Invalid Date". probably need to look into the resolver on the server side

EDIT:

Here's an extended patch to make sure expiration date is transmitted and parsed properly. @nicolaslopezj i'll be willing to PR if you take this

// RE: https://github.com/orionsoft/meteor-apollo-accounts/issues/90
const schema = getSchema();
schema.typeDefs = schema.typeDefs.replace('tokenExpires: Float!', 'tokenExpires: String!');
_.extend(schema.resolvers.LoginMethodResponse, schema.resolvers.LoginMethodResponse, {
  tokenExpires({ tokenExpires }) {
    return tokenExpires.toString();
  },
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants