-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Relay 0.5.0 invariant expects query to be empty, 0.4.0 worked fine #585
Comments
@LegNeato can you paste your route definition? |
I'm using const OnboardingDataQueries = {
onboarding_data: (Component) => Relay.QL`
query {
onboarding_data {
${Component.getFragment('onboarding_data')},
},
}
`,
}; <Route path="/account/setup/type" component={AccountTypeOnboardingPage} queries={OnboardingDataQueries} /> ...
static fragments = {
onboarding_data: () => Relay.QL`
fragment on OnboardingData {
id,
accountType,
}
`,
};
}
export default Relay.createContainer(AccountTypeOnboardingPage, {
fragments: {
onboarding_data: () => Relay.QL`
fragment on OnboardingData {
id,
accountType,
${AccountTypeOnboardingMutation.getFragment('onboarding_data')},
}
`,
},
}); |
@LegNeato what browser are you using? Relay checks the function length to see whether it takes arguments - your query definition ( |
Could you paste what the code looks like transformed? Maybe it's the way the arrow function is transformed in your pipeline that breaks this detection? |
@josephsavona latest Chrome. Attached is a (crappy) screenshot with values from the debugger. |
From the screenshot, it appears that |
The call to const OnboardingDataQueries = {
onboarding_data: (Component) => Relay.QL`...`
} ...and it has 1 argument. How does the arrow function look like transformed? |
var OnboardingDataQueries = {
onboarding_data: function onboarding_data(Component) {
return (function (sub_0) {
return {
children: [{
fieldName: 'id',
kind: 'Field',
metadata: {
parentType: 'OnboardingData',
isGenerated: true,
isRequisite: true
}
}, _reactRelay2['default'].QL.__frag(sub_0)],
fieldName: 'onboarding_data',
kind: 'Query',
metadata: {},
name: 'App'
};
})(Component.getFragment('onboarding_data'));
}
}; FWIW I'm using pretty standard babel (5, not 6) and webpack AFAIK. But I am a JS n00b :-D. |
This looks like a problem with function() {
return query(component, routeParams);
} |
Cool, do you want me to close this out or is it a behavior/expectation change that needs to be reverted in relay? |
I think I just need to update this on my side. |
Although I am curious what changed. |
This is expected behavior for Relay; |
@taion We previously allowed argument-less query builders to have fragments, but this doesn't make sense. The stricter check is here: c9baf7f#commitcomment-14343423 |
Thanks! I'm going to roll this fix on my side into part of a broader fix now that I have some new APIs available on the React Router side as well. Should have this fixed soon. |
@LegNeato for your case the shorthand version might fix your immediate issue (at least for this case): const OnboardingDataQueries = {
onboarding_data: () => Relay.QL`
query {
onboarding_data
}
`,
}; |
Sounds good, i'll close this out but feel free to continue the discussion here. |
Getting this error with Relay 0.5.0:
Everything worked fine with 0.4.0. I have the latest GraphQL and React.
Not sure what info you need to debug or if the issue is on my side and 0.4.0 is more tolerant...let me know what you need.
The text was updated successfully, but these errors were encountered: