Duration: 45-60 minutes
Stack: Vue 3, @vue/apollo-composable, GraphQL
Difficulty: Intermediate
Implement a user management interface that displays users in a table format with pagination capabilities using GraphQL with Apollo Client.
Use the provided GraphQL query to fetch users:
Query Variables for user list and invitation:
{
filter: { and: [], or: [] },
sorting: [],
page: 1,
per_page: 5
},
{
name,
username,
organisation: { id } , // get organisation id from user store
roles: { id },
}
Apollo Settings for each query:
{
fetchPolicy: 'no-cache'
}
Create a UserListView.vue
component with:
- Table Layout: Use CSS Grid or Flexbox (your choice)
- Columns: ID, Name, Username, MFA Status, Created Date
- Loading State: Show loading indicator during fetch
- Error Handling: Display error messages appropriately
- Empty State: Handle when no users are found
Implement pagination functionality:
- Show current page and total pages
- Previous/Next buttons
- Page number display
- Disable buttons when appropriate (first/last page)
- Update query variables when page changes
- Create UserInviteView.vue
- 2 required fields with input email and role selection (with radio button list: Admin with id 1 , Observer with id 3, User with id 2)
- one button to submit form
- on submit validate required fields and send inviteUser mutations(see /apollo/mutations/invite-user.gql)
- get organisation id for requrest from pinia authStore
- mutation
import { useQuery } from '@vue/apollo-composable'
Since you won't have a real GraphQL endpoint, create a mock response:
// Expected response format
{
data: {
users: {
items: [
{
id: "1",
name: "John Doe",
username: "john.doe",
mfa_active: true,
created: "2024-01-15T10:30:00Z"
},
{
id: "2",
name: "Jane Smith",
username: "jane.smith",
mfa_active: false,
created: "2024-01-10T14:22:00Z"
},
{
id: "3",
name: "Bob Wilson",
username: "bob.wilson",
mfa_active: true,
created: "2024-01-08T09:15:00Z"
},
// ... more users
],
meta: {
count: 50,
per_page: 5,
pages: 10
}
}
}
}
- 0-15 min: Set up GraphQL query and Apollo integration
- 15-35 min: Build table component with data display
- 35-45 min: Implement pagination functionality
- 45-55 min: Add styling and UX improvements
- 55-60 min: Final testing and refinements
By the end of the session, the candidate should have:
- ✅ Working GraphQL query using the provided schema
- ✅ Table displaying user data (ID, Name, Username, MFA Status, Created)
- ✅ Functional pagination controls
- ✅ Proper loading and error state handling
- ✅ Clean, professional appearance
- ✅ Responsive design considerations
- Advanced responsive design (mobile-friendly table)
- Custom loading spinner
- Smooth transitions and animations
- Accessibility features (ARIA labels, keyboard navigation)
- Error retry functionality
- Per-page selection dropdown
- Table row click handlers
- Not handling loading/error states properly
- Incorrect query variable structure for the new schema
- Missing fetchPolicy configuration
- Poor responsive table implementation
- Not implementing proper pagination state management
- Forgetting to handle empty states
- Hardcoding values instead of using reactive data
This challenge uses a specific GraphQL schema where:
- Response data is in
users.items
(notusers.data
) - Meta information uses
count
instead oftotal
- Meta uses
pages
instead oflast_page
- User fields include
username
instead ofemail
The candidate should demonstrate adaptability to different API schemas and data structures.