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

[playground] Infinity is reported as null #367

Open
czerwinskilukasz1 opened this issue Jul 8, 2020 · 2 comments · May be fixed by #505
Open

[playground] Infinity is reported as null #367

czerwinskilukasz1 opened this issue Jul 8, 2020 · 2 comments · May be fixed by #505
Labels
bug Something isn't working discussion A discussion is taking place, please don't work on it yet DX/CLI/Playground developer experience

Comments

@czerwinskilukasz1
Copy link
Collaborator

Consider the following program:

ask {
  const factorial: int(int) = fun(n:int):int {
    if (n < 2) {
      return n
    }

    n * factorial(n - 1)
  }

  200:factorial
}

In CLI the result is:

float ask(const('factorial',fun(let('n',get('$0')),if(call(get('<'),get('n'),2),block(return(get('n'))),block()),call(get('*'),get('n'),call(get('factorial'),call(get('-'),get('n'),1))))),call(get('factorial'),200))
Infinity
🦄 

However, Playground displays:

null
@YonatanKra
Copy link
Collaborator

@czerwinskilukasz1 that is because of how JSON works: http://www.ecma-international.org/publications/standards/Ecma-404.htm
So:

JSON.stringify(Infinity); //null
JSON.stringify(NaN); //null

@mhagmajer mhagmajer added the discussion A discussion is taking place, please don't work on it yet label Oct 9, 2020
@mhagmajer
Copy link
Contributor

@czerwinskilukasz1 as I understand the playground should showcase the scenario of client-server communication where client sends AskQL query and receives a JSON response back. JSON is the widely accepted format of data transfer so it makes sens to keep it for transporting the response. That's also how Graphi works for GraphQL. I don't think we're able to return Infinity or NaN back to the client from the server in JSON. What's your idea for handling that? Should we even allow Infinity or NaN as a result of AskQL query?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working discussion A discussion is taking place, please don't work on it yet DX/CLI/Playground developer experience
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants