> This page is for Manufacturing Data Model API.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://autodesk.ferndocs.com/mfgdata/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://autodesk.ferndocs.com/mfgdata/_mcp/server.

# GraphQL Query Examples

This page provides example queries you can use with the Sample GraphQL API. Each example includes the query, variables, and expected response.

## Query Examples

#### Get User by ID

Retrieve a single user with all their fields:

```graphql
query GetUser($id: ID!) {
  user(id: $id) {
    id
    name
    email
    role
    createdAt
  }
}
```

**Variables:**

```json
{
  "id": "usr_abc123"
}
```

**Response:**

```json
{
  "data": {
    "user": {
      "id": "usr_abc123",
      "name": "Jane Smith",
      "email": "jane@example.com",
      "role": "EDITOR",
      "createdAt": "2025-01-15T10:30:00Z"
    }
  }
}
```

#### List Users (Paginated)

Fetch a paginated list of users:

```graphql
query ListUsers($limit: Int, $after: String) {
  users(limit: $limit, after: $after) {
    edges {
      node {
        id
        name
        email
        role
      }
      cursor
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}
```

**Variables:**

```json
{
  "limit": 10,
  "after": null
}
```

**Response:**

```json
{
  "data": {
    "users": {
      "edges": [
        {
          "node": {
            "id": "usr_abc123",
            "name": "Jane Smith",
            "email": "jane@example.com",
            "role": "EDITOR"
          },
          "cursor": "Y3Vyc29yMQ=="
        },
        {
          "node": {
            "id": "usr_def456",
            "name": "John Doe",
            "email": "john@example.com",
            "role": "VIEWER"
          },
          "cursor": "Y3Vyc29yMg=="
        }
      ],
      "pageInfo": {
        "hasNextPage": true,
        "endCursor": "Y3Vyc29yMg=="
      }
    }
  }
}
```

#### Create User

Create a new user with role assignment:

```graphql
mutation CreateUser($input: CreateUserInput!) {
  createUser(input: $input) {
    id
    name
    email
    role
    createdAt
  }
}
```

**Variables:**

```json
{
  "input": {
    "name": "Alice Johnson",
    "email": "alice@example.com",
    "role": "ADMIN"
  }
}
```

**Response:**

```json
{
  "data": {
    "createUser": {
      "id": "usr_ghi789",
      "name": "Alice Johnson",
      "email": "alice@example.com",
      "role": "ADMIN",
      "createdAt": "2025-06-01T14:22:00Z"
    }
  }
}
```

#### Update User

Update specific fields on an existing user:

```graphql
mutation UpdateUser($id: ID!, $input: UpdateUserInput!) {
  updateUser(id: $id, input: $input) {
    id
    name
    role
  }
}
```

**Variables:**

```json
{
  "id": "usr_abc123",
  "input": {
    "role": "ADMIN"
  }
}
```

**Response:**

```json
{
  "data": {
    "updateUser": {
      "id": "usr_abc123",
      "name": "Jane Smith",
      "role": "ADMIN"
    }
  }
}
```

#### Delete User

Permanently remove a user:

```graphql
mutation DeleteUser($id: ID!) {
  deleteUser(id: $id)
}
```

**Variables:**

```json
{
  "id": "usr_abc123"
}
```

**Response:**

```json
{
  "data": {
    "deleteUser": true
  }
}
```

## Error Handling

GraphQL errors are returned in the `errors` array alongside partial `data`:

```json
{
  "data": {
    "user": null
  },
  "errors": [
    {
      "message": "User not found",
      "path": ["user"],
      "extensions": {
        "code": "NOT_FOUND"
      }
    }
  ]
}
```