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

type lookup in hint fails #868

Closed
timsuchanek opened this issue Jan 12, 2018 · 15 comments
Closed

type lookup in hint fails #868

timsuchanek opened this issue Jan 12, 2018 · 15 comments

Comments

@timsuchanek
Copy link
Member

Hi,

we're using the codemirror-graphql in the GraphQL Playground and experience problems, that the type property of a suggestion is undefined.
It happens in this line of code:
https://github.com/graphql/codemirror-graphql/blob/master/src/hint.js#L66

The problem is, that item.detail can contain ! in the case of a non-nullable type.
item.detail comes from here https://github.com/graphql/graphql-language-service/blob/master/packages/interface/src/getAutocompleteSuggestions.js#L97

schema.getType() however is just returning getTypeMap()[name] - as there is no type with the name User!, undefined is returned.
https://github.com/graphql/graphql-js/blob/master/src/type/schema.js#L182

Now is the question what the solution for this could be.
The quick-fix, that would work for us, is just not calling .getType() in hint anymore.
But I guess that the type lookup has been added for a reason.

@asiandrummer would be awesome to hear your take on that.

Thanks!

@asiandrummer
Copy link
Contributor

asiandrummer commented Feb 1, 2018

@timsuchanek sorry for getting to this late. This looks like a bug - thanks for finding it! I guess it's not only for non-nullable types - list types could also cause a problem here, no?

I can't remember why exactly we're looking up a type here. I'm assuming this type lookup is there because we want to validate if the type name from item.detail is in fact existing in the schema provided. I think a correct fix is to determine if a type is a "wrapping type" and deal with each case properly. Thankfully it seems like we already have helper methods to work with these!

Would you be interested in creating PR for the fix maybe?

cc @schickling

@acao acao transferred this issue from graphql/codemirror-graphql Jun 19, 2019
@acao
Copy link
Member

acao commented Jun 22, 2019

@timsuchanek thanks for your fix for this, I'm going to consider this resolved

@acao acao closed this as completed Jun 22, 2019
yoshiakis added a commit to yoshiakis/graphiql that referenced this issue Jun 28, 2019
yoshiakis added a commit to yoshiakis/graphiql that referenced this issue Jun 28, 2019
yoshiakis added a commit to yoshiakis/graphiql that referenced this issue Jun 29, 2019
yoshiakis added a commit to yoshiakis/graphiql that referenced this issue Jul 1, 2019
@acao acao reopened this Dec 2, 2019
@acao
Copy link
Member

acao commented Dec 2, 2019

@yoshiakis is this not resolved yet? i think i mistook the PR above as having solved this

@acao acao added the bug label Dec 2, 2019
@acao acao self-assigned this Dec 2, 2019
@yoshiakis
Copy link
Contributor

@acao This issue is not solved yet. Sorry for stopping fixing this issue. Can I continue to be responsible to solve this issue? I think I can throw fixed PR in 1 or 2 weeks.

@acao
Copy link
Member

acao commented Dec 3, 2019

would love your help, you are right on track already, that timeline sounds perfect!

yoshiakis added a commit to yoshiakis/graphiql that referenced this issue Jan 17, 2020
yoshiakis added a commit to yoshiakis/graphiql that referenced this issue Jan 18, 2020
yoshiakis added a commit to yoshiakis/graphiql that referenced this issue Jan 19, 2020
yoshiakis added a commit to yoshiakis/graphiql that referenced this issue Jan 19, 2020
yoshiakis added a commit to yoshiakis/graphiql that referenced this issue Jan 19, 2020
yoshiakis added a commit to yoshiakis/graphiql that referenced this issue Jan 20, 2020
yoshiakis added a commit to yoshiakis/graphiql that referenced this issue Jan 21, 2020
yoshiakis added a commit to yoshiakis/graphiql that referenced this issue Jan 23, 2020
yoshiakis added a commit to yoshiakis/graphiql that referenced this issue Jan 23, 2020
yoshiakis added a commit to yoshiakis/graphiql that referenced this issue Jan 23, 2020
yoshiakis added a commit to yoshiakis/graphiql that referenced this issue Jan 24, 2020
@acao
Copy link
Member

acao commented Apr 6, 2020

@yoshiakis this is in [email protected] which now has graphql 15 support! enjoy

@acao acao closed this as completed May 4, 2020
@yoshiakis
Copy link
Contributor

@acao would you please reopen this issue? Unfortunately, this issue hasn't been fixed yet. I'm currently modifying the test code in a branch which needs to be merged to fix this issue.

@acao acao reopened this May 4, 2020
@acao acao added this to the GraphiQL-1.0.0 milestone May 4, 2020
@acao
Copy link
Member

acao commented May 31, 2020

@yoshiakis i merged as is, and I can add more tests in another PR, is that ok?

@yoshiakis
Copy link
Contributor

yoshiakis commented May 31, 2020

@acao yeah, it's ok. and thank you for merging! I want to do other PRs for refactoring and adding test cases and changing code of hint.js a little bit because the way how the value of documentation in completion list is determined has been slightly changed by the merging, which didn't consider #1541.

@acao
Copy link
Member

acao commented Jun 16, 2020

@yoshiakis @timsuchanek do we feel this bug is resolved now?

@yoshiakis
Copy link
Contributor

@acao yeah, i think so :) (refactoring the test cases still remains, but the bug has been fixed so I think this issue can be closed.)

@acao
Copy link
Member

acao commented Jun 16, 2020

speaking of which, do you have any reccomendations for getting flow + typescript working side by side in vscode? i can't seem to get it working without temporarily disabling Check JS for the entire workspace. it's been an issue since the typescript conversion

@acao
Copy link
Member

acao commented Jun 16, 2020

also, thank you @yoshiakis so very much for your stewardship of codemirror-graphql!

@yoshiakis
Copy link
Contributor

yoshiakis commented Jun 16, 2020

unfortunately, i don't know either. it's a pain to disable Check JS every time, though :(

@acao
Copy link
Member

acao commented Jun 16, 2020

closing now, if any new issues with this arise with codemirror-graphql, please open a new bug ticket! thanks everyone for all your help on this!

@acao acao closed this as completed Jun 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants