write-sample-data
Fill an Endless Studios view's system.user and system.sample (store state, store handlers and GraphQL responses) so the copied app components render the intended role, status and permission state. Use
Files5
View on GitHubSKILL.mdsrc/systems/endless-studios/skills/write-sample-data/SKILL.md
GitHubWrite sample data
A view's export const system = { user, sample: { state, getters, mutations, actions, queries } } is everything the app around a copied component knows. The system README is the contract for the options; data shapes records how the stand-ins in runtime/ answer and what the app receives. A gap is an [Endless Studios] warning in the console: the stand-in found no sample and rendered empty. A wrong sample is silent, so a clean console is necessary, not sufficient.
Give each named state the sample its experience needs, and every value the response shape: what the query returns to the component, keyed the way the component reads it, never the schema's type layout.
Steps
Collect the gaps. Load the view and each named state at its own address, reloading between them: a gap is reported once per page, so one already shown for another state stays silent. Open every popover, tab and modal the state shows, because a component queries only when it mounts: the shell's notifications popover asks for
NOTIFICATIONS_LISTonly when opened. Record each warning:Console says Add query "X" has no sample responsesample.queries.Xmutation "X" has no sample responsesample.queries.X(mutations share the map)store action "x" is not stood insample.actions.xstore mutation "X" is not stood insample.mutations.Xunknown sample user …a preset name, a user object or null(step 4)missing translation "key"not a sample gap: the key is missing from the copied locale files subscriptions are not stood in,GraphQLClient.request is not stood innothing a sample answers; report it as a runtime follow-up Lines logged with
console.info(navigation, login requested, error toast) are not gaps. Also note each copied component that renders empty or wrong without a gap.Done when every state has its list of gaps and silent failures.
Read each operation in the copied source. Find the
gqldocument by operation name in the view or the system'sstudios/andruntime/folders (grep -rn "query X\b\|mutation X\b" src/systems/endless-studios). Note its root fields and aliases, every nested field the template or script reads, and its options:auth(requiredby default, so a signed-out state gets the default;anonymousis the reverse),flattenData,transform,default, and whetheruseStreamingGraphQLQueryruns it. For data a component takes as props, read itsdefineProps. Data shapes lists what each copied component reads at the copy's revision.Check field names, nullability and enum values against the live schema rather than any copy of it, with an account that can read the private app repository:
gh api -H 'Accept: application/vnd.github.raw' 'repos/Endless-Game-Making-Studio/studio/contents/backend/gql-schema.graphql?ref=dev'Use
?ref=<revision>from studios/README.md for the schema the copied components were written against. Without access, use the references here and say so in the report.Done when every gap and silent failure has an operation name, its root response keys and the fields read.
Shape each response. Write
sample.queries[Operation]in response shape, as the query'sdata: keyed by alias where the document has one, with only the selected fields, lists as arrays, and__typenameon union results. Give a function of the variables when the answer depends on them. A mutation's sample is its return value:Voidisnull. Store state merges over the app's initial state; supply the actions the components dispatch. The rules and common shapes are in data shapes.Keep a sample the view alone uses as constants in its regular
<script>, and one several views share in a helper folder such as_data/. A state'ssamplereplaces the view's whole, so build it from the view's ({ ...sample, queries: { ...sample.queries, X: … } }), as build-prototype step 10 describes.Done when each sample's top-level keys equal the operation's root response keys and every field the component reads is present, null only where the state means it.
Choose the user. Use a preset (
'learner','mentor','admin') only when the state depends on nothing they lack; otherwise paste the role's object from users by role, which says what the presets lack. Usenullfor signed out: required queries then resolve to their defaults and streaming lists stay empty. What each role may do is in Platform model.Done when each state's user gives the
$authchecks the screen branches on (isAdmin,isCohortAdmin,isAdult…) and its age category, consent, restricted-partner and disabled fields match the state.Check statuses and permissions. Compare every status, kind, phase and permission value with state enums, or the live schema, on the field that takes it:
ProgramStatusisinprogresswhileCohortStatusisin_progress, andpermissions.publishis the one boolean. Make the user and each entity'spermissionstell one story: a youth without consent seesparental_consent_requiredwherever the schema gives it, a restricted partnerrestricted_partner, a signed-out visitornot_authenticatedornot_member.Done when no value falls outside its enum and no permission contradicts the user.
Make it believable. Take people, programs, cohorts and games from the demo cast and follow its content rules: real words instead of placeholders, uneven counts and reactions, timestamps a few days to weeks old, and youth usernames in the Adjective+Animal+Number pattern. Text arrives already translated, so a Spanish state's sample is in Spanish; product wording follows Voice and tone.
Done when no sample holds lorem ipsum, "Test", or numbered filler such as "Program 1".
Verify. Reload each named state at its own address, open its overlays, read the console and look at the screen. If the preview errors, follow build-prototype step 14.
Done
Every named state renders the experience it names, its console shows no [Endless Studios] gaps, and every status, kind and permission value matches the schema. Report each state's user and sampled operations, any gap no sample can answer, and any value you could not check against the live schema.