-
Notifications
You must be signed in to change notification settings - Fork 5
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
Update/documentation/extending last looks #320
Update/documentation/extending last looks #320
Conversation
docs/extending/data-source.md
Outdated
return $zipcode_data_source->to_array()['service_config']['endpoint'] . $input_variables['zip_code']; | ||
'data_source' => $comp_data_source, | ||
'endpoint' => function ( array $input_variables ) use ( $comp_data_source ): string { | ||
return return $comp_data_source->get_endpoint() . $zipcode_data_source->to_array()['service_config']['some_identifier'] . "/" . $input_variables['search']; |
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.
Mentioned on the other PR, but I don't think we should promote this pattern. It constrains us in future changes and this alternate approach is unnecessary. They can just hold a reference to some_identifier
in their own code and pass it in via use()
. This should definitely not be idiomatic.
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.
When I look at the Airtable Data Source we add a base
property to the data source definition, that's was my inspiration.
I think your suggesting that additional configuration should happen outside of service_config, so something like:
$data_source = HttpDataSource::from_array( [
'service_config' => [
'__version' => 1,
'display_name' => 'More Complicated Example API',
'endpoint' => 'https://api.complexexample.com/',
'request_headers' => [
'Content-Type' => 'application/json',
'X-Api-Key' => MY_API_KEY_CONSTANT,
],
],
] );
$my_config = [
'some_identifier' => 'id-123'
]
$zipcode_query = HttpQuery::from_array( [
'data_source' => $data_source,
'endpoint' => function ( array $input_variables ) use ( $data_source, $my_config ): string {
return return $data_source->get_endpoint() . $my_config['some_identifier'] . "/" . $input_variables['search'];
},
])
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.
Yes, exactly
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.
I applied your suggestion in a781b4c
Co-authored-by: Chris Zarate <[email protected]>
…m:Automattic/remote-data-blocks into update/documentation/extending-last-looks
Co-authored-by: Chris Zarate <[email protected]>
Co-authored-by: Chris Zarate <[email protected]>
Co-authored-by: Chris Zarate <[email protected]>
Co-authored-by: Chris Zarate <[email protected]>
Co-authored-by: Chris Zarate <[email protected]>
Co-authored-by: Chris Zarate <[email protected]>
Co-authored-by: Chris Zarate <[email protected]>
Co-authored-by: Chris Zarate <[email protected]>
…m:Automattic/remote-data-blocks into update/documentation/extending-last-looks
…/extending-last-looks
This finishes my pass at the documentation for now.
Thanks all for the thoughtful reviews!