{"id":20831977,"url":"https://github.com/graphql-dotnet/example-orders","last_synced_at":"2025-05-08T00:41:49.616Z","repository":{"id":72747355,"uuid":"123356667","full_name":"graphql-dotnet/example-orders","owner":"graphql-dotnet","description":"GraphQL order management example","archived":false,"fork":false,"pushed_at":"2019-07-08T13:18:22.000Z","size":511,"stargazers_count":32,"open_issues_count":5,"forks_count":13,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-05-08T00:41:42.536Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/graphql-dotnet.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-02-28T23:50:34.000Z","updated_at":"2022-03-19T23:41:22.000Z","dependencies_parsed_at":"2024-01-23T21:18:59.513Z","dependency_job_id":"6ece35c1-27d3-485d-9955-063e69a27db5","html_url":"https://github.com/graphql-dotnet/example-orders","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-dotnet%2Fexample-orders","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-dotnet%2Fexample-orders/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-dotnet%2Fexample-orders/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-dotnet%2Fexample-orders/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graphql-dotnet","download_url":"https://codeload.github.com/graphql-dotnet/example-orders/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252978671,"owners_count":21834911,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T00:09:43.290Z","updated_at":"2025-05-08T00:41:49.598Z","avatar_url":"https://github.com/graphql-dotnet.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Example-Orders\nA sample GraphQL order management endpoint using GraphQL for .NET. This is a more advanced version of the example I used in my course [API Development in .NET with GraphQL](https://www.lynda.com/NET-tutorials/API-Development-NET-GraphQL/664823-2.html)\n\n## Running the sample\n* If using Visual Studio, open `Orders-GraphQL.sln` build and run\n* On Mac/Linux go the `Server` folder and run `dotnet run -f netcoreapp2.0`\n\n## Overview\nThis endpoint contains 2 core data types\n* Orders - Orders that have been added to the system\n* Customers - Customers for each order\n\n## API\n### Queries\n#### orders\nRetrieves a list of orders\n\nexample:\n```\nquery getOrders {\n  orders {\n    id\n    name\n    description\n    customer {\n        name\n    }\n  }\n}\n```\n#### orderById\nRetrieves a specified order\n\n*Arguments*\n* orderId - The id of the order\n\nexample:\n```\nquery getOrder {\n  orderById(orderId: \"FAEBD971-CBA5-4CED-8AD5-CC0B8D4B7827\") {\n    id\n    name\n    description\n  }\n}\n```\n#### customers\nRetrieves all customers\n\nexample:\n```\nquery getCustomers {\n  customers {\n    id\n    name\n  }\n}\n```\n### Mutations\n#### createOrder\nCreates an order\n\n*Arguments*\n* order - Information for the order to be created.\n\nexample:\n```\nmutation createOrder{\n  createOrder(order:\n    {\n      name:\"Glenn\",\n      description:\"Test\",\n      customerId: 1,\n      created: \"03/16/2018\"\n    }\n  ) \n  {\n    id\n    name\n  }\n}\n```\n#### startOrder\nStarts the processing of an order. Can only be called if the order is in a `CREATED` state.\n\n*Arguments*\n* orderId - The id of the order\n\nexample starting an order\n```\nmutation startOrder {\n  startOrder(orderId: \"FAEBD971-CBA5-4CED-8AD5-CC0B8D4B7827\") {\n    id\n    status\n  }\n}\n```\n#### completeOrder\nFinishes the processing of an order. Can only be called if the order is in the `PROCESSING` state.\n\n*Arguments*\n* orderId - The id of the order\n\nexample completing an order\n```\nmutation completeOrder {\n  completeOrder(orderId: \"FAEBD971-CBA5-4CED-8AD5-CC0B8D4B7827\") {\n    id\n    status\n  }\n}\n```\n#### cancelOrder\nCancels an order. Can only be called if the order is not in the `COMPLETED` or `CANCELLED` state.\n\n*Arguments*\n* orderId - The id of the order\n\nexample cancelling an order\n```\nmutation cancelOrder {\n  cancelOrder(orderId: \"FAEBD971-CBA5-4CED-8AD5-CC0B8D4B7827\") {\n    id\n    status\n  }\n}\n```\n#### closeOrder\nCloses an order. Can only be called if the order is in the `COMPLETED` state.\n\n*Arguments*\n* orderId - The id of the order\n\nexample closing an order\n```\nmutation closeOrder {\n  closeOrder(orderId: \"FAEBD971-CBA5-4CED-8AD5-CC0B8D4B7827\") {\n    id\n    status\n  }\n}\n```\n### Subscriptions\nYou can use subscriptions to get notified when an order is created. This relies on the awesome [GraphQL Server](https://github.com/graphql-dotnet/server) project.\n\nTo test out subscriptions, you'll want to open two graphiql instances. One for subscribing, and the other for performing a mutation.\n\n#### orderEvent\nNotifies when order status changes.\n\n*Arguments*\n* statuses (optional) - An array of one or more statuses to receive notifications on\n\nexample subscribing to all order updates\n```\nsubscription createdEvent {\n  orderEvent {\n    id\n    name\n    status\n  }\n}\n```\n\nexample subscribing to order started events\n```\nsubscription startedEvent {\n  orderEvent ([PROCESSING]) {\n    id\n    name\n    status\n  }\n}\n```\n\n## Solution Structure\n* Server - Contains the GraphQL Server / wires up GraphQL.NET middleware\n* Orders - Contains models and the GraphQL Schema\n  * Models - Contains the underlying models which drive the schema\n  * Services - Contains data services for retrieving and updating models, as well as for notifications. Services are registered with the ASP.NET Core container allowing them to be injected wherever need.\n  * Schema - Contains the GraphQL types, queries, mutuations and subscriptions.\n\n## License\nApache 2.0\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphql-dotnet%2Fexample-orders","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraphql-dotnet%2Fexample-orders","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphql-dotnet%2Fexample-orders/lists"}