-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[1.0] WIP fix infer graphql input type #908
Conversation
Deploy preview failed. Built with commit 9703e59 https://app.netlify.com/sites/gatsbygram/deploys/590a42716f4c505dfdfb6391 |
Deploy preview failed. Built with commit 9703e59 https://app.netlify.com/sites/gatsbyjs/deploys/590a426f6f4c505dfdfb638e |
Deploy preview ready! Built with commit 9703e59 |
I'd imagine that the problem is that the type is getting created multiple times in a loop somewhere. In general for the inference bits it may be helpful to have a type map/cache to avoid this sort of thing. E.g. you can only have 1 instance of a GraphQLType with the same |
@@ -24,6 +24,10 @@ describe(`GraphQL Input args`, () => { | |||
title: `The world of dash and adventure`, | |||
blue: 100, | |||
}, | |||
anObjectArray: [ | |||
{ aString: `some string`, aNumber: 2, aBoolean: true }, | |||
{ aString: `some string`, aNumber: 2, anArray: [1, 2] }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the idea that these are the same type but each is missing a different field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. I do think properties that hold an array should be able to be empty or not, but for starters I think it would be ok if objects always have to have the same keys. And if the data doesn't some out of the CMS like that it's still easy to fix in client code.
Did you pull the latest code? I think I fixed the problem you're seeing yesterday in #897 |
@KyleAMathews Yes this was based on the most recent code. There were no tests for object arrays yet for this part of the code. |
Ooo right this is for input code. |
Yeah you probably just need this then
|
@KyleAMathews yes that was the missing piece! 🎉 Going to wrap this up. I don't really know how to write the test for this. That one is still failing with the same message:
But my application code is working. If you could have a look at the test to see if I did something stupid I can make the test pass maybe. Otherwise I'll just remove it for now. |
🎉 Lemme pull down your code real quick and see what's happening. |
@KyleAMathews I'm about to go to sleep. Will pick this up tomorrow morning. The last commit adds the createTypeName function. I made it shared (with one register). I assumed type names should be globally unique anyway. |
Here's the changes I made to get this working. I didn't use snapshots a lot elsewhere but they're a lot easier than fiddling with the long access chains. |
Just got this in locally 7b45d92 |
I still can't query object arrays from my data.
Managed to get a bit further but now my app complains
Schema must contain unique named types but contains multiple types named "categoryTagsInputObject".
AndcategoryTags
in this case is the key that contains the object array in my data.I'm sure it's something simple again, but I can't fully grasp it.