Energinet-DataHub / greenforce-frontend

GreenForce monorepo for the DataHub and Energy Origin frontends. Part of Energinet DataHub.
Apache License 2.0
72 stars 13 forks source link

feat(dh): apollo signal reset function #3316

Closed ManBearTM closed 3 months ago

ManBearTM commented 3 months ago

This PR makes it possible to reset queries and mutations to an initial, pending state, essentially clearing the result fields. This can come in handy if, for example, you are using lazyQuery to do some validations in combination with computed:

validation = lazyQuery(GetUserByEmailDocument);

userExists = computed(() => this.validation.data()?.user ? true : false);

resetForm() {
  // This will cause `userExists` to be `false` again
  this.validation.reset();
}

async validate(email: string) {
  await validation.query({ variables: { email }});
}
nx-cloud[bot] commented 3 months ago

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 29e65d043c78e12acf810e239bb54e27a3d1f7bf. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 5 targets - [`nx affected:test --base=origin/main`](https://cloud.nx.app/runs/Xi6fBLPM1F?utm_source=pull-request&utm_medium=comment) - [`nx affected:build --configuration=production --base=origin/main`](https://cloud.nx.app/runs/oTi4gB36ri?utm_source=pull-request&utm_medium=comment) - [`nx affected:lint --max-warnings=0 --fix --parallel --base=origin/main`](https://cloud.nx.app/runs/sZ5XpzIXNN?utm_source=pull-request&utm_medium=comment) - [`nx affected:e2e --configuration=ci --base=origin/main`](https://cloud.nx.app/runs/JcyUChyrj6?utm_source=pull-request&utm_medium=comment) - [`nx affected -t component-test --base=origin/main`](https://cloud.nx.app/runs/kq7V9LaBP6?utm_source=pull-request&utm_medium=comment)

Sent with 💌 from NxCloud.