Skip to content

Commit

Permalink
refactor: add @loopback/example-graphql
Browse files Browse the repository at this point in the history
Signed-off-by: Raymond Feng <[email protected]>
  • Loading branch information
raymondfeng committed Aug 19, 2020
1 parent 0564ee2 commit 328bfa1
Show file tree
Hide file tree
Showing 32 changed files with 1,376 additions and 272 deletions.
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@
# - Issue label: GraphQL
# - Primary owner(s): @raymondfeng
/extensions/graphql @raymondfeng
/examples/graphql @raymondfeng

#
# Build & internal tooling
Expand Down
1 change: 1 addition & 0 deletions docs/site/MONOREPO.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ one in the monorepo: `npm run update-monorepo-file`
| [examples/context](https://github.com/strongloop/loopback-next/tree/master/examples/context) | @loopback/example-context | Standalone examples to illustrate features provided by @loopback/context |
| [examples/express-composition](https://github.com/strongloop/loopback-next/tree/master/examples/express-composition) | @loopback/example-express-composition | LoopBack 4 REST API on Express |
| [examples/file-transfer](https://github.com/strongloop/loopback-next/tree/master/examples/file-transfer) | @loopback/example-file-transfer | Example application for file upload/download with LoopBack 4 |
| [examples/graphql](https://github.com/strongloop/loopback-next/tree/master/examples/graphql) | @loopback/example-graphql | GraphQL Example Application |
| [examples/greeter-extension](https://github.com/strongloop/loopback-next/tree/master/examples/greeter-extension) | @loopback/example-greeter-extension | An example showing how to implement the extension point/extension pattern using LoopBack 4 |
| [examples/greeting-app](https://github.com/strongloop/loopback-next/tree/master/examples/greeting-app) | @loopback/example-greeting-app | An example greeting application for LoopBack 4 |
| [examples/hello-world](https://github.com/strongloop/loopback-next/tree/master/examples/hello-world) | @loopback/example-hello-world | A simple hello-world Application using LoopBack 4 |
Expand Down
1 change: 1 addition & 0 deletions examples/graphql/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=true
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Copyright (c) IBM Corp. 2019.
Node module: graphql-test
Copyright (c) IBM Corp. 2020.
Node module: @loopback/example-graphql
This project is licensed under the MIT License, full text below.

--------

MIT License

MIT License Copyright (c) IBM Corp. 2019
MIT License Copyright (c) IBM Corp. 2020

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
75 changes: 75 additions & 0 deletions examples/graphql/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# @loopback/example-graphql

An example application to demonstrate GraphQL integration for LoopBack 4 using
[@loopback/graphql](https://github.com/strongloop/loopback-next/tree/graphql/extensions/graphql).

## Try it out

```sh
npm start
```

You should see the following messages:

```sh
Server is running at http://[::1]:3000
Try http://[::1]:3000/graphql
```

Open http://127.0.0.1:3000/graphql in your browser to play with the GraphiQL.

![graphql-demo](graphql-demo.png)

1. Copy the query to the right panel:

```graphql
query GetRecipe1 {
recipe(recipeId: "1") {
title
description
ratings
creationDate
ratingsCount(minRate: 2)
averageRating
ingredients
numberInCollection
}
}
```

2. Click on the run icon:

```json
{
"data": {
"recipe": {
"title": "Recipe 1",
"description": "Desc 1",
"ratings": [0, 3, 1],
"creationDate": "2018-04-11T00:00:00.000Z",
"ratingsCount": 1,
"averageRating": 1.3333333333333333,
"ingredients": ["one", "two", "three"],
"numberInCollection": 1
}
}
}
```

## Contributions

- [Guidelines](https://github.com/strongloop/loopback-next/blob/master/docs/CONTRIBUTING.md)
- [Join the team](https://github.com/strongloop/loopback-next/issues/110)

## Tests

Run `npm test` from the root folder.

## Contributors

See
[all contributors](https://github.com/strongloop/loopback-next/graphs/contributors).

## License

MIT
File renamed without changes
Loading

0 comments on commit 328bfa1

Please sign in to comment.