Skip to content

Commit 94f1273

Browse files
authored
Merge pull request #36 from rasmusjp/release/0.1.0
Update readme
2 parents eb983ba + ca0e110 commit 94f1273

File tree

3 files changed

+113
-51
lines changed

3 files changed

+113
-51
lines changed

README.md

Lines changed: 93 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Umbraco GraphQL
1+
# GraphQL for Umbraco
2+
[![NuGet release](https://img.shields.io/nuget/v/Our.Umbraco.GraphQL.svg)](https://www.nuget.org/packages/Our.Umbraco.GraphQL)
23

34
## What is this
45
An experimental implementation of [GraphQL](https://graphql.org) for Umbraco using [GraphQL for .NET](https://github.com/graphql-dotnet/graphql-dotnet).
@@ -12,14 +13,22 @@ An Owin middleware exposes Umbraco Published Content as a GraphQL endpoint.
1213

1314
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.
1415

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.
16+
## Installation
1617

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.
18+
The preferred way to install GraphQL for Umbraco is through NuGet
1819

19-
## Getting started
20-
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`.
20+
### Option 1: NuGet
21+
22+
GraphQL for Umbraco is available as a NuGet [package](https://www.nuget.org/packages/Our.Umbraco.GraphQL).
23+
24+
To install run the following command in the [Package Manager Console](https://docs.nuget.org/docs/start-here/using-the-package-manager-console)
2125

22-
There's also a [download](https://drive.google.com/file/d/1L67kZV7u6tXy45zknLih421Rlbrx3fh3/view) which contains a prebuilt website with some sample data based on the starter kit. Login `[email protected]`/`1234567890`. It's based on the Umbraco starter kit, where `People`, `Products` and `Blog` has been moved to the root of the tree.
26+
```powershell
27+
PM> Install-Package Our.Umbraco.GraphQL
28+
```
29+
30+
### Option 2: From source
31+
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`.
2332

2433
### Urls
2534
| Url | Description |
@@ -29,87 +38,123 @@ There's also a [download](https://drive.google.com/file/d/1L67kZV7u6tXy45zknLih4
2938
| /umbraco/graphql/schema | The generated schema |
3039

3140
### Querying
32-
Query examples based on the download above
33-
41+
Query examples based on The Starter Kit
3442
```graphql
3543
{
36-
people {
37-
pageTitle
38-
children {
39-
items {
40-
... on Person {
41-
name
42-
department
43-
photo {
44-
url
44+
content {
45+
byType {
46+
People(id: "1116") {
47+
pageTitle
48+
_contentData {
49+
children {
50+
items {
51+
... on Person {
52+
_contentData {
53+
name
54+
}
55+
department
56+
photo {
57+
_contentData {
58+
url
59+
}
60+
}
61+
}
62+
}
4563
}
4664
}
4765
}
4866
}
4967
}
5068
}
69+
5170
```
5271

5372
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`
5473
```graphql
5574
{
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
75+
content {
76+
byType {
77+
People(id: "1116") {
78+
pageTitle
79+
_contentData {
80+
peopleStartsWithJ: children(filter: {name_starts_with: "J"}, orderBy: name_ASC) {
81+
items {
82+
... on Person {
83+
_contentData {
84+
name
85+
}
86+
department
87+
photo {
88+
_contentData {
89+
url
90+
}
91+
}
92+
}
93+
}
6594
}
6695
}
6796
}
6897
}
6998
}
7099
}
100+
71101
```
72102

73-
And even query for multiple roots at the same time
103+
And even query for multiple types at the same time
74104
```graphql
75105
{
76-
people {
77-
pageTitle
78-
peopleStartsWithJ: children(filter: {name_starts_with: "J"}, orderBy: name_ASC) {
79-
items {
80-
...SimplePerson
106+
content {
107+
byType {
108+
People(id: "1116") {
109+
pageTitle
110+
_contentData {
111+
peopleStartsWithJ: children(filter: {name_starts_with: "J"}, orderBy: name_ASC) {
112+
items {
113+
...SimplePerson
114+
}
115+
}
116+
}
81117
}
82-
}
83-
}
84-
products {
85-
pageTitle
86-
defaultCurrency
87-
featuredProducts {
88-
...SimpleProduct
89-
}
90-
children {
91-
items {
92-
...SimpleProduct
118+
Products(id: "1107") {
119+
pageTitle
120+
defaultCurrency
121+
featuredProducts {
122+
...SimpleProduct
123+
}
124+
_contentData {
125+
children {
126+
items {
127+
...SimpleProduct
128+
}
129+
}
130+
}
93131
}
94132
}
95133
}
96134
}
97135

98136
fragment SimplePerson on Person {
99-
name
137+
_contentData {
138+
name
139+
}
100140
department
101141
photo {
102-
url
142+
_contentData {
143+
url
144+
}
103145
}
104146
}
105147

106148
fragment SimpleProduct on Product {
107-
name
149+
_contentData {
150+
name
151+
}
108152
price
109153
sku
110154
photos {
111-
url
155+
_contentData {
156+
url
157+
}
112158
}
113159
}
114-
115160
```

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<title>Umbraco GraphQL</title>
4-
<authors>rasmusjp</authors>
5-
<description>GraphQL for Umbraco</description>
3+
<title>GraphQL for Umbraco</title>
4+
<authors>Rasmus John Pedersen, Offroadcode</authors>
5+
<owners>rasmusjp, Offroadcode</owners>
6+
<description>A GraphQL server for Umbraco</description>
67
<packageLicenseUrl>https://github.com/rasmusjp/umbraco-graphql/raw/master/LICENSE</packageLicenseUrl>
78
<packageProjectUrl>https://github.com/rasmusjp/umbraco-graphql</packageProjectUrl>
89
<packageTags>umbraco umbracocms graphql</packageTags>
@@ -32,6 +33,7 @@
3233
<None Include="tools\**" Pack="True" PackagePath="tools\" />
3334
<None Include="$(UIRoot)dist\**" Pack="True" PackagePath="content\" />
3435
<None Include="content\**" Pack="True" PackagePath="content\" />
36+
<None Include="readme.txt" Pack="True" PackagePath="" />
3537
</ItemGroup>
3638

3739
<ItemGroup>

src/Our.Umbraco.GraphQL/readme.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
_____ _ _____ _ __ _ _ _
2+
| __ \ | | | _ | | / _| | | | | | |
3+
| | \/_ __ __ _ _ __ | |__ | | | | | | |_ ___ _ __ | | | |_ __ ___ | |__ _ __ __ _ ___ ___
4+
| | __| '__/ _` | '_ \| '_ \| | | | | | _/ _ \| '__| | | | | '_ ` _ \| '_ \| '__/ _` |/ __/ _ \
5+
| |_\ \ | | (_| | |_) | | | \ \/' / |____ | || (_) | | | |_| | | | | | | |_) | | | (_| | (_| (_) |
6+
\____/_| \__,_| .__/|_| |_|\_/\_\_____/ |_| \___/|_| \___/|_| |_| |_|_.__/|_| \__,_|\___\___/
7+
| |
8+
|_|
9+
10+
This package currently is intended for development-level testing right now.
11+
12+
All doctypes and media properties are accessible via the GraphQL endpoint by anyone, as permissions and other security features aren't yet present.
13+
Don't use this on any data you need to keep protected
14+
15+
For more info visit https://github.com/rasmusjp/umbraco-graphql/

0 commit comments

Comments
 (0)