Skip to content

Commit 7cd7238

Browse files
committed
Update examples
1 parent 77f1426 commit 7cd7238

File tree

2 files changed

+80
-46
lines changed

2 files changed

+80
-46
lines changed

README.md

Lines changed: 79 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Umbraco GraphQL
1+
# GraphQL for Umbraco
22

33
## What is this
44
An experimental implementation of [GraphQL](https://graphql.org) for Umbraco using [GraphQL for .NET](https://github.com/graphql-dotnet/graphql-dotnet).
@@ -12,9 +12,7 @@ An Owin middleware exposes Umbraco Published Content as a GraphQL endpoint.
1212

1313
GraphQL types are dynamically generated for all Umbraco document types (content and media), with all the properties as fields. They all implement an interface `PublishedContent` which implements the generic Umbraco properties as fields.
1414

15-
If a document type is alloweded at root, a field on the query is generated with the same name as the document type alias.
1615

17-
There are also two generic fields `content(id: ID!)` and `contentAtRoot` which can be used to query by `id` or getting all root content.
1816

1917
## Getting started
2018
Clone the repository and run the Website (F5 in Visual Studio), install Umbraco with the starter kit and start exploring the API using GraphiQL by opening `/umbraco/graphiql`.
@@ -29,87 +27,123 @@ There's also a [download](https://drive.google.com/file/d/1L67kZV7u6tXy45zknLih4
2927
| /umbraco/graphql/schema | The generated schema |
3028

3129
### Querying
32-
Query examples based on the download above
33-
30+
Query examples based on The Starter Kit
3431
```graphql
3532
{
36-
people {
37-
pageTitle
38-
children {
39-
items {
40-
... on Person {
41-
name
42-
department
43-
photo {
44-
url
33+
content {
34+
byType {
35+
People(id: "1116") {
36+
pageTitle
37+
_contentData {
38+
children {
39+
items {
40+
... on Person {
41+
_contentData {
42+
name
43+
}
44+
department
45+
photo {
46+
_contentData {
47+
url
48+
}
49+
}
50+
}
51+
}
4552
}
4653
}
4754
}
4855
}
4956
}
5057
}
58+
5159
```
5260

5361
We can also do some simple filtering and sorting, ([Inspired by the Grahpcool filtering](https://www.graph.cool/docs/reference/graphql-api/query-api-nia9nushae#query-arguments)) like geting all children of people that starts with the letter `J`
5462
```graphql
5563
{
56-
people {
57-
pageTitle
58-
peopleStartsWithJ:children(filter: { name_starts_with:"J"}, orderBy: name_ASC) {
59-
items {
60-
... on Person {
61-
name
62-
department
63-
photo {
64-
url
64+
content {
65+
byType {
66+
People(id: "1116") {
67+
pageTitle
68+
_contentData {
69+
peopleStartsWithJ: children(filter: {name_starts_with: "J"}, orderBy: name_ASC) {
70+
items {
71+
... on Person {
72+
_contentData {
73+
name
74+
}
75+
department
76+
photo {
77+
_contentData {
78+
url
79+
}
80+
}
81+
}
82+
}
6583
}
6684
}
6785
}
6886
}
6987
}
7088
}
89+
7190
```
7291

73-
And even query for multiple roots at the same time
92+
And even query for multiple types at the same time
7493
```graphql
7594
{
76-
people {
77-
pageTitle
78-
peopleStartsWithJ: children(filter: {name_starts_with: "J"}, orderBy: name_ASC) {
79-
items {
80-
...SimplePerson
95+
content {
96+
byType {
97+
People(id: "1116") {
98+
pageTitle
99+
_contentData {
100+
peopleStartsWithJ: children(filter: {name_starts_with: "J"}, orderBy: name_ASC) {
101+
items {
102+
...SimplePerson
103+
}
104+
}
105+
}
81106
}
82-
}
83-
}
84-
products {
85-
pageTitle
86-
defaultCurrency
87-
featuredProducts {
88-
...SimpleProduct
89-
}
90-
children {
91-
items {
92-
...SimpleProduct
107+
Products(id: "1107") {
108+
pageTitle
109+
defaultCurrency
110+
featuredProducts {
111+
...SimpleProduct
112+
}
113+
_contentData {
114+
children {
115+
items {
116+
...SimpleProduct
117+
}
118+
}
119+
}
93120
}
94121
}
95122
}
96123
}
97124

98125
fragment SimplePerson on Person {
99-
name
126+
_contentData {
127+
name
128+
}
100129
department
101130
photo {
102-
url
131+
_contentData {
132+
url
133+
}
103134
}
104135
}
105136

106137
fragment SimpleProduct on Product {
107-
name
138+
_contentData {
139+
name
140+
}
108141
price
109142
sku
110143
photos {
111-
url
144+
_contentData {
145+
url
146+
}
112147
}
113148
}
114-
115149
```

src/Our.Umbraco.GraphQL/Our.Umbraco.GraphQL.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<title>Umbraco GraphQL</title>
3+
<title>GraphQL for Umbraco</title>
44
<authors>Rasmus John Pedersen, Offroadcode</authors>
55
<owners>rasmusjp, Offroadcode</owners>
66
<description>A GraphQL server for Umbraco</description>

0 commit comments

Comments
 (0)