@grantjs/schema
v1.0.0
Published
GraphQL schema and generated types for Grant
Readme
@grantjs/schema
GraphQL schema and generated types for the Grant.
Overview
This package contains:
- GraphQL schema definitions
- Generated TypeScript types
- GraphQL operations and resolvers
- Additional platform-specific types
Installation
npm install @grantjs/schemaUsage
Basic Types
import { User, Role, Permission, Organization, Project } from '@grantjs/schema';
const user: User = {
id: '1',
email: '[email protected]',
// ... other properties
};GraphQL Operations
import { GetUsersQuery, CreateUserMutation } from '@grantjs/schema';
// Use in your GraphQL operations
const GET_USERS = gql`
query GetUsers {
users {
id
email
roles {
id
name
}
}
}
`;Resolvers
import { Resolvers } from '@grantjs/schema';
const resolvers: Resolvers = {
Query: {
users: () => {
// Your resolver implementation
},
},
};Development
Generate Types
# Generate types from GraphQL schema
pnpm generate
# Watch for changes and regenerate
pnpm generate:watchBuild Package
pnpm buildSchema Structure
src/
├── schema/ # GraphQL schema definitions
│ ├── permissions/ # Permission-related types and operations
│ ├── users/ # User-related types and operations
│ ├── roles/ # Role-related types and operations
│ ├── groups/ # Group-related types and operations
│ ├── organizations/ # Organization-related types and operations
│ ├── projects/ # Project-related types and operations
│ └── tags/ # Tag-related types and operations
├── generated/ # Generated TypeScript files
│ ├── types.ts # Generated types
│ ├── operations.ts # Generated operations
│ └── resolvers.ts # Generated resolvers
└── types/ # Additional TypeScript types
└── index.ts # Context and additional typesContributing
When modifying the GraphQL schema:
- Update the relevant
.graphqlfiles insrc/schema/ - Run
pnpm generateto regenerate types - Update any affected resolvers or operations
- Test the changes
License
MIT License - see LICENSE for details.
