Skip to content

Add @schema decorator to mark namespaces as GraphQL schemas - #1

Closed
steverice wants to merge 1 commit into
feature/graphqlfrom
schema-decorator
Closed

Add @schema decorator to mark namespaces as GraphQL schemas#1
steverice wants to merge 1 commit into
feature/graphqlfrom
schema-decorator

Conversation

@steverice

Copy link
Copy Markdown

Using the TypeSpec.GraphQL.@schema decorator on a namespace indicates that the decorated namespace represents a GraphQL schema that should be generated by the GraphQL emitter.

Because this allows for multiple schemas to be specified in a TypeSpec source, our test host is reworked to provide a GraphQLSchemaRecord corresponding to each schema produced.

This commit does not actually implement any emitter functionality, but populates a state map that will be used by the emitter in the future.

@steverice
steverice requested a review from swatkatz as a code owner November 12, 2024 22:03
@steverice

Copy link
Copy Markdown
Author

Note to reviewers: the first commit is just some package.json metadata that I have proposed directly upstream: microsoft#5076

@AngelEVargas AngelEVargas left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I suppose my personal GH user is already working!

Comment thread packages/graphql/src/lib/schema.ts Outdated
Comment on lines +14 to +15
// This will set the namespace for all the decorators
export const namespace = "TypeSpec.GraphQL";

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Suggested change
// This will set the namespace for all the decorators
export const namespace = "TypeSpec.GraphQL";

This should not be needed when using export const $decorators.

@steverice steverice Nov 14, 2024

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Turns out we do need this. When we import schema.js into schema.tsp, the definition must be namespaced in order to match the TypeSpec declaration.

So we have two different paths for namespacing:

  1. export const $decorators in tsp-index.js sets the namespace explicitly for all decorators when used by external code
  2. export const namespace = in schema.js sets the namespace when the $schema decorator is imported directly.

Since these are two independent import paths, they should not conflict.

@steverice
steverice force-pushed the schema-decorator branch 4 times, most recently from bb18a3a to c0fff8a Compare November 18, 2024 22:35
Comment thread packages/graphql/package.json
Comment thread packages/graphql/package.json
Comment thread packages/graphql/package.json
{
"name": "@typespec/graphql",
"version": "0.1.0",
"author": "Microsoft Corporation",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is this true?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

As I mentioned, these package.json updates have been proposed upstream on their own. So I am hoping to get MSFT's input on what should and shouldn't be in package.json as I think it's ultimately up to them.

Until that, I am mostly just copying things over from other packages (primarily openapi3).

Comment thread packages/graphql/src/lib.ts Outdated
Comment thread packages/graphql/lib/schema.tsp
Comment thread packages/graphql/src/lib/schema.ts Outdated
Comment thread packages/graphql/src/testing/utils.ts Outdated
Comment thread packages/graphql/test/schema.test.ts Outdated
Comment thread packages/graphql/test/test-host.ts

@swatkatz swatkatz left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Just a small comment to add the test mode thing as a comment to the test runner.

Comment thread packages/graphql/test/test-host.ts
@steverice
steverice force-pushed the schema-decorator branch 2 times, most recently from 9b12057 to f87595e Compare November 20, 2024 22:52
Using the `TypeSpec.GraphQL.@schema` decorator on a namespace indicates that the decorated namespace represents a GraphQL schema that should be generated by the GraphQL emitter.

Because this allows for multiple schemas to be specified in a TypeSpec source, our test host is reworked to provide a `GraphQLTestResult` corresponding to each schema produced.

This commit does not actually implement any emitter functionality, but populates a state map that will be used by the emitter in the future.
@steverice

Copy link
Copy Markdown
Author

This was merged upstream, so I'm closing out this PR.

@steverice steverice closed this Nov 26, 2024
steverice pushed a commit that referenced this pull request Feb 17, 2026
…icrosoft#9713)

Upgrades http-client-python dependencies to match root package.json
versions for consistency across the monorepo.

## Dependencies Updated

- **@types/node**: ~24.1.0 → ~25.0.2
- **rimraf**: ~6.0.1 → ~6.1.2
- **tsx**: ~4.19.1 → ^4.21.0
- **typescript**: ~5.8.2 → ~5.9.2
- **typescript-eslint**: ^8.21.0 → ^8.49.0
- **vitest**: ^3.1.2 → ^4.0.15

## Changes

- Updated `packages/http-client-python/package.json` with aligned
versions
- Regenerated `package-lock.json` via `npm install`
- Added changelog entry with `changeKind: dependencies`

<!-- START COPILOT ORIGINAL PROMPT -->



<details>

<summary>Original prompt</summary>

update dependencies of packages/http-client-python/package.json. If they
are found it package.json, upgrade to same version. NOTE: PR title shall
starts with "[python]"

<analysis>
[Chronological Review:  
- The user provided a timestamp and requested: **“clean all changes”**.
- Assistant initiated a parallel tool call with:
  1) `functions.report_intent` (intent logging), and  
  2) `functions.powershell` to run a git cleanup command chain.  
- PowerShell command executed:  
`git --no-pager status --short && git reset --hard HEAD && git clean -fd
&& git --no-pager status --short`
- Tool output showed there was a modified file before reset (`M
packages/http-client-python/package.json`), then successful hard reset
to commit `efbf17ff8`, and successful completion (exit code 0).
- Assistant then ran a second verification command:  
  `git --no-pager status --short`  
  which returned no output and exit code 0 (clean working tree).  
- Assistant called `functions.task_complete` with a summary indicating
all tracked/untracked changes were removed and cleanliness verified.
- Assistant replied to user: repo is clean.  
- User then asked for a structured conversation summary emphasizing
recent commands/tool results.]

[Intent Mapping:  
- Explicit user request #1: **“clean all changes”** (clear local tracked
and untracked changes).
- Explicit user request #2: Summarize conversation history with emphasis
on recent commands/results and no additional tool calls.
- Implicit expectation: confirm repo cleanliness after cleanup and
provide a handoff-quality summary.]

[Technical Inventory:  
- Version control: **Git**.  
- Commands used: `git status --short`, `git reset --hard HEAD`, `git
clean -fd`.
- Agent tooling: `multi_tool_use.parallel`, `functions.report_intent`,
`functions.powershell`, `functions.task_complete`.
- Environment note from user reminder: no SQL tables currently exist;
SQL tool was not used.]

[Code Archaeology:  
- Mentioned file: `packages/http-client-python/package.json` (was
modified before cleanup).
- No new code edits were made; all local edits were discarded.  
- Repository state restored to `HEAD` commit `efbf17ff8` with no
remaining local diffs/untracked files.]

[Progress Assessment:  
- Completed: workspace cleanup and verification.  
- Pending: none from original cleanup task.  
- New active task: produce detailed structured summary (current
response).]

[Context Validation:  
- Captured user goals, all tool calls, exact command strings, key
outputs, and final repo state.
- Captured immediate pre-summary state (cleanup completed, user
requested summary).
- Noted that summarization was user-triggered; no evidence of an actual
runtime token-overflow event in the visible transcript.]

[Recent Commands Analysis:  
- Last agent commands executed:
- `functions.report_intent` with `intent: "Cleaning workspace"` →
result: “Intent logged”.
  - `functions.powershell` command chain for cleanup and status checks.
- Follow-up `functions.powershell` with `git --no-pager status --short`
for explicit verification.
  - `functions.task_complete` with cleanup summary.
- Key tool results:
- Pre-clean status included `M
packages/http-client-python/package.json`.
  - `git reset --hard HEAD` succeeded: `HEAD is now at efbf17f ...`.
- Final status checks returned clean output (empty `git status
--short`), exit code 0.
- Immediate pre-summarization state: task already completed and
user-confirmed response sent; then user requested this summary.]
</analysis>

<summary>
1. Conversation Overview:
   - Primary Objectives:
     - User requested: **“clean all changes”**.
- Later requested: **“Summarize the conversation history so far, paying
special attention to the most recent agent commands and tool
results...”**
   - Session Context:
- Single operational task session: detect local changes, discard
everything, verify clean state, report completion.
   - User Intent Evolution:
     - Started with repo cleanup.
- Shifted to documentation/handoff summary of what was executed and what
results were returned.

2. Technical Foundation:
   - Git CLI:
     - Used to inspect and forcibly restore working tree state.
   - Agent Tooling:
- `multi_tool_use.parallel` for concurrent intent logging + shell
action.
     - `functions.powershell` for command execution.
     - `functions.task_complete` for formal completion marker.
   - Workflow Pattern:
- Execute destructive cleanup (`reset --hard` + `clean -fd`) then verify
with explicit status check.
   - Environment Detail:
- User reminder included SQL tool note (“No tables currently exist...”),
but no SQL operations were performed.

3. Codebase Status:
   - `packages/http-client-python/package.json`:
     - Purpose: package metadata/config for python HTTP client package.
- Current State: previously modified; modification discarded by hard
reset.
     - Key Code Segments: none discussed.
     - Dependencies: only r...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

Created from Copilot CLI via the copilot delegate command.

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com>
Co-authored-by: Yuchao Yan <yuchaoyan@microsoft.com>
mauriciogardini pushed a commit that referenced this pull request Jun 10, 2026
…vscode (microsoft#10847)

# Improve telemetry instrumentation and error diagnostics

## Summary

Based on analysis of 2 weeks of telemetry data (71K+ events, 2,327
unique users), this PR improves telemetry instrumentation gaps and error
diagnostics across the typespec-vscode extension and the compiler LSP
server.

## Changes

### Extension telemetry improvements (`packages/typespec-vscode`)

**`install-tsp-compiler.ts`** — Added `lastStep` tracking and
`logOperationDetailTelemetry` for failure/timeout cases. Previously, all
3 install failures in the dataset had `lastStep=undefined` and zero
error detail.

**`openapi3-preview.ts`** — Refactored `getOpenApi3OutputFilePath` to
return `Result<string>` instead of `string | undefined` to properly
distinguish compile failures from user cancellations. Added `lastStep`
for the success path (`"Preview panel opened"`). Added compile error
details to telemetry.

**`extension.ts` (start-server)** — Added `lastStep` for the "compiler
not found" state before the install prompt, and for the
cancelled-install path. These covered 66 events (34 fail + 32 cancelled)
that previously had `lastStep=undefined`.

**`extension.ts` (server-path-changed)** — Added `lastStep` for the
config change handler. All 30 events previously had
`lastStep=undefined`.

### Better error message for node/tsp not on PATH
(`packages/typespec-vscode`)

**`tsp-executable-resolver.ts`** — When the compiler is found locally
but neither `node` nor `tsp` is available on PATH, the extension now
shows an actionable error message explaining the likely cause
(nvm/fnm/volta PATH not inherited) and three concrete fixes. Previously,
this silently fell through to `spawn tsp ENOENT`. This was the #1 root
cause of blocked users — 107 failure events from users who never
recovered.

### Server-side error detail preservation (`packages/compiler`)

**`serverlib.ts`** — Added `wrapUnhandledError` wrapper around all LSP
server handlers. When a handler crashes, the wrapper catches the error
and re-throws with the full server-side stack trace in the error message
(via `inspect(e)`). Previously, the JSON-RPC layer only forwarded
`error.message` to the client, so the server-side crash location was
completely lost in telemetry. This addresses the 297 `Cannot read
properties of undefined (reading 'kind')` errors that were previously
opaque.

## Telemetry data highlights

- **2,327 total users** in the 2-week window
- **101 users (4.3%) completely blocked** — never had a successful
`start-server` in 2 weeks
- **#1 root cause**: `spawn tsp ENOENT` (node not on PATH) — 107 events
from never-recovered users, disproportionately macOS (60%)
- **#2 root cause**: compiler not found — 50 events
- **297 `reading 'kind'` unhandled errors** — now will include
server-side stack for future diagnosis

---------

Co-authored-by: Timothee Guerin <timothee.guerin@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants