Use index patterns service inside data plugin (rather than importing from ui/public)#41639
Conversation
|
Pinging @elastic/kibana-app-arch |
💔 Build Failed |
lukeelmers
left a comment
There was a problem hiding this comment.
Another way you could do this would be importing from the top level (../../public) as mentioned in the IndexPatterns TS PR. That way we use the same "official" contracts between services that any other plugins would use:
// i want to import static code from another service within the data plugin
import { IndexPattern } from '../../../public';
// i want to use runtime dependencies from another service within the data plugin
class DataPlugin {
setup(core, deps) {
const indexPatterns = this.indexPatterns.setup();
return {
indexPatterns,
myService: this.myService.setup({ indexPatterns })
};
}
}
MyService.setup({ indexPatterns });
// i want to use an internal method from another service & it is not publicly exposed from `data`
import { InternalThing } from '../../index_patterns';
// ^ makes it clear when we are relying on something internal to the data plugin|
@lukeelmers I'm not sure how I feel about the static code import style, in a comlpex plugin like Take this line for example: import { Field, IndexPattern } from '../../../index_patterns';If we go with this approach, this line will become: import { Field, IndexPattern } from '../../../';
What do you think? |
|
I agree I think this illustrates a larger decision we need to make which is how we organize our static exports by service to make them easier for devs to consume. That way you don't lose the context of which service you are dealing with when importing from public/index. But for now, I think your approach importing from services |
…from ui/public) (elastic#41639) * Use index patterns from data plugin itself instead of importing from ui/public * Added mocks to field editor util tests
* upstream/7.x: Ensure visualizations in percentage mode respect the advanced settings percent format (elastic#39044) (elastic#41855) [7.x] [telemetry] Analytics Package (elastic#41113) (elastic#41774) [Uptime] Improve `useUrlParams` hook for Uptime app (elastic#41545) (elastic#41818) [Maps] refactor filter actions to use embeddable actions (elastic#41713) (elastic#41821) [Maps] clean up tooltip header and footer (elastic#41793) (elastic#41816) [SIEM] Timeline NOT working with unauthorized (elastic#41767) (elastic#41873) Use index patterns service inside data plugin (rather than importing from ui/public) (elastic#41639) (elastic#41867)
Summary
Use index patterns service inside data plugin (rather than importing from ui/public)
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.For maintainers