Skip to content

Commit 0e39650

Browse files
qucik start prisma
1 parent 99380fd commit 0e39650

File tree

3 files changed

+1425
-0
lines changed

3 files changed

+1425
-0
lines changed

README.md

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ A high-performance, embedded, GraphQL-native database engine written in C# for .
2424

2525
### Documentation
2626

27+
- [**⚡ Quick Start**](docs/quick-start.md) - Get up and running in 5 minutes with Star Wars example
2728
- [Getting Started Guide](docs/getting-started.md) - Installation and quick start tutorials
29+
- [**Filtering & Sorting Guide**](docs/filtering-guide.md) - Prisma-style filtering, sorting, pagination with examples
2830
- [Features](docs/features.md) - Schema-driven development, GraphQL support, storage engine
2931
- [Configuration](docs/configuration.md) - Database configuration and settings
3032
- [API Reference](docs/api-reference.md) - Complete API documentation
@@ -78,6 +80,243 @@ var result = executor.Execute(@"{
7880
}");
7981
```
8082

83+
## Prisma-Style Filtering & Sorting
84+
85+
SharpGraph supports Prisma-style filtering and sorting through Connection types. This provides an intuitive, GraphQL-native way to query and sort data.
86+
87+
### Filtering with `where`
88+
89+
Filter records using field-level conditions:
90+
91+
```graphql
92+
query SearchCharacters {
93+
characters {
94+
items(where: {name: {contains: "Luke"}}) {
95+
id
96+
name
97+
characterType
98+
}
99+
}
100+
}
101+
```
102+
103+
**Available filter operators:**
104+
- `equals`: Exact match
105+
- `contains`: String contains (case-insensitive)
106+
- `startsWith`: String starts with
107+
- `endsWith`: String ends with
108+
- `gt`: Greater than (for numbers)
109+
- `lt`: Less than (for numbers)
110+
- `gte`: Greater than or equal
111+
- `lte`: Less than or equal
112+
113+
**Combined filters with AND/OR/NOT:**
114+
115+
```graphql
116+
query FindHumans {
117+
characters {
118+
items(where: {
119+
AND: [
120+
{characterType: {equals: "Human"}}
121+
{name: {contains: "Solo"}}
122+
]
123+
}) {
124+
id
125+
name
126+
characterType
127+
}
128+
}
129+
}
130+
```
131+
132+
### Sorting with `orderBy` (Prisma-style)
133+
134+
Sort by one or multiple fields using Prisma's intuitive syntax:
135+
136+
```graphql
137+
query SortedCharacters {
138+
characters {
139+
items(orderBy: [{name: asc}]) {
140+
id
141+
name
142+
characterType
143+
}
144+
}
145+
}
146+
```
147+
148+
**Multiple sort fields (applied in order):**
149+
150+
```graphql
151+
query MultiSortCharacters {
152+
characters {
153+
items(orderBy: [{characterType: asc}, {name: asc}]) {
154+
id
155+
name
156+
characterType
157+
height
158+
}
159+
}
160+
}
161+
```
162+
163+
### Pagination with `skip` and `take`
164+
165+
Paginate through results:
166+
167+
```graphql
168+
query PaginatedCharacters {
169+
characters {
170+
items(skip: 0, take: 10) {
171+
id
172+
name
173+
characterType
174+
}
175+
}
176+
}
177+
```
178+
179+
### Combined: Filter, Sort, and Paginate
180+
181+
```graphql
182+
query AdvancedQuery {
183+
characters {
184+
items(
185+
where: {characterType: {equals: "Human"}}
186+
orderBy: [{name: asc}]
187+
skip: 0
188+
take: 5
189+
) {
190+
id
191+
name
192+
characterType
193+
height
194+
mass
195+
}
196+
}
197+
}
198+
```
199+
200+
## Auto-Generated CRUD Mutations
201+
202+
SharpGraph automatically generates Create, Update, and Delete mutations for every entity in your schema. No configuration needed!
203+
204+
### Create Mutation
205+
206+
```graphql
207+
mutation CreateCharacter {
208+
createCharacter(input: {
209+
name: "Luke Skywalker"
210+
characterType: "Human"
211+
appearsIn: ["NEWHOPE", "EMPIRE", "JEDI"]
212+
height: 172.72
213+
mass: 77.0
214+
hairColor: "Blond"
215+
skinColor: "Fair"
216+
eyeColor: "Blue"
217+
birthYear: "19BBY"
218+
homePlanetId: "tatooine"
219+
}) {
220+
id
221+
name
222+
characterType
223+
}
224+
}
225+
```
226+
227+
### Update Mutation
228+
229+
```graphql
230+
mutation UpdateCharacter {
231+
updateCharacter(
232+
id: "luke"
233+
input: {
234+
name: "Luke Skywalker (Updated)"
235+
height: 173.0
236+
}
237+
) {
238+
id
239+
name
240+
height
241+
}
242+
}
243+
```
244+
245+
### Delete Mutation
246+
247+
```graphql
248+
mutation DeleteCharacter {
249+
deleteCharacter(id: "luke")
250+
}
251+
```
252+
253+
### Bulk Operations Example
254+
255+
```graphql
256+
mutation CreateMultiple {
257+
c1: createCharacter(input: {
258+
name: "Character 1"
259+
characterType: "Human"
260+
}) {
261+
id
262+
name
263+
}
264+
265+
c2: createCharacter(input: {
266+
name: "Character 2"
267+
characterType: "Droid"
268+
}) {
269+
id
270+
name
271+
}
272+
}
273+
```
274+
275+
## Complete CRUD Example
276+
277+
```graphql
278+
# Create
279+
mutation {
280+
createFilm(input: {
281+
title: "A New Hope"
282+
episodeId: 4
283+
openingCrawl: "It is a period of civil war..."
284+
director: "George Lucas"
285+
producer: "Gary Kurtz"
286+
releaseDate: "1977-05-25"
287+
}) {
288+
id
289+
title
290+
}
291+
}
292+
293+
# Read with Filtering
294+
query {
295+
films {
296+
items(where: {title: {contains: "Hope"}}) {
297+
id
298+
title
299+
episodeId
300+
}
301+
}
302+
}
303+
304+
# Update
305+
mutation {
306+
updateFilm(id: "1", input: {
307+
title: "Star Wars: Episode IV - A New Hope"
308+
}) {
309+
id
310+
title
311+
}
312+
}
313+
314+
# Delete
315+
mutation {
316+
deleteFilm(id: "1")
317+
}
318+
```
319+
81320
## Key Features
82321

83322
- ** Schema-Driven**: Define your database with GraphQL SDL - no C# classes needed

0 commit comments

Comments
 (0)