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

Update/documentation/extending last looks #320

Merged
merged 29 commits into from
Jan 27, 2025

Conversation

smithjw1
Copy link
Contributor

This finishes my pass at the documentation for now.

Thanks all for the thoughtful reviews!

@smithjw1 smithjw1 self-assigned this Jan 22, 2025
docs/quickstart.md Outdated Show resolved Hide resolved
docs/extending/overrides.md Outdated Show resolved Hide resolved
docs/extending/overrides.md Outdated Show resolved Hide resolved
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'];
Copy link
Member

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.

Copy link
Contributor Author

@smithjw1 smithjw1 Jan 25, 2025

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'];
    },
])

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly

Copy link
Member

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

smithjw1 and others added 20 commits January 24, 2025 16:14
…m:Automattic/remote-data-blocks into update/documentation/extending-last-looks
…m:Automattic/remote-data-blocks into update/documentation/extending-last-looks
@chriszarate chriszarate merged commit 0ae1d02 into trunk Jan 27, 2025
12 checks passed
@chriszarate chriszarate deleted the update/documentation/extending-last-looks branch January 27, 2025 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants