A useful pattern when doing component-based design is to have each component specify a graphql Fragment it needs for its data, and the data loading interface imports this fragment somehow:
# File butterfly_painter.py
FRAGMENT= '''
fragment Foo on Butterfly {
wingColor
}
'''
def paint_butterfly(butterfly: Butterfly):
return f'<img src="/img/wings/{butterfly_color}.png">'
So that if paint_butterfly is changed, the piece of the query it needs can me modified in the same file, instead of somewhere else.
This pattern has some issues, but the use-case (localizing data required for a component to the component) is important and we should support some way to handle it.
A useful pattern when doing component-based design is to have each component specify a graphql Fragment it needs for its data, and the data loading interface imports this fragment somehow:
So that if
paint_butterfly
is changed, the piece of the query it needs can me modified in the same file, instead of somewhere else.This pattern has some issues, but the use-case (localizing data required for a component to the component) is important and we should support some way to handle it.