-
-
Notifications
You must be signed in to change notification settings - Fork 566
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
Deprecate callbacks in field types #35
Comments
Is there any reason why? What's the motivation behind this change? |
This seems redundant. Also first notation adds some performance overhead because every field type has to be checked with Pretty much everything you can do with first notation can be done with second as well. Also that's how reference js implementation works. It turns out that maintaining this library is way easier when there is little deviation from reference implementation (at least until things settle down with GraphQL itself). But if you have any use-cases which require this feature - please describe them. That's pretty much the reason why I created these issues - to start a discussion if somebody needs them %) |
👍 for this change! it will be much more easier to implements dynamics fields without having to used hacks. |
Done in c11f257 |
must compliment you guys for referincing this issue in the actual error message! 🥇 |
Is there any chance the first notation could be permitted once again ? |
@Alexandru-Dobre We can discuss it, but first I would like to figure out why it is impossible to change the code of your library for this notation (as it is also the only way reference js implementation allows you to define fields). I am pretty sure there should be a way to do this. What will happen if you change these lines to: $typeArray = [
'name' => $type['name'],
'fields' => function() use ($type) {
$fields = [];
foreach ($type['fields'] as $fieldKey => $fieldValue) {
$fields[$fieldKey] = $this->buildField($fieldKey, $fieldValue);
}
return $fields;
}
];
if (!empty($type['description'])) {
$typeArray['description'] = $type['description'];
}
$this->alambicTypes[$typeName] = new ObjectType($typeArray); Obviously you will have to remove closure for Why this will not work? |
@vladar Thank you for the suggestion! It worked perfectly with minimum changes to our library code. The rest of the method doesn't need closures as only the "fields" part was exposed to a cyclic dependency issue (models for SQL databases had foreign keys pointing to each other) since we automatically exclude non-scalar fields as query args. |
Nice! |
Deprecate following field definition form:
in favor of:
The text was updated successfully, but these errors were encountered: