From 7a2ff0cf4adf18cda2e455d10ef616328855662d Mon Sep 17 00:00:00 2001 From: Fiyaz Bin Hasan Date: Wed, 14 Jul 2021 15:33:00 +0600 Subject: [PATCH 1/6] lot of refactoring --- GraphQL.Relay.sln | 32 +- src/GraphQL.Relay.Todo/.babelrc | 8 - src/GraphQL.Relay.Todo/.gitignore | 232 + src/GraphQL.Relay.Todo/ClientApp/.env | 1 + .../ClientApp/.env.development | 1 + src/GraphQL.Relay.Todo/ClientApp/README.md | 2228 ++ .../ClientApp/components/TodoApp.js | 83 - .../__generated__/TodoApp_viewer.graphql.js | 52 - .../ClientApp/package-lock.json | 16959 ++++++++++++++++ src/GraphQL.Relay.Todo/ClientApp/package.json | 65 + .../ClientApp/public/favicon.ico | Bin 0 -> 5430 bytes .../ClientApp/public/index.html | 41 + .../ClientApp/public/manifest.json | 15 + src/GraphQL.Relay.Todo/ClientApp/src/App.js | 53 + .../ClientApp/src/App.test.js | 13 + .../ClientApp/src/RelayEnvironment.js | 15 + .../src/__generated__/AppQuery.graphql.js | 111 + .../ClientApp/src/components/Header.js | 21 + .../ClientApp/src/components/Link.js | 26 + .../ClientApp/src/components/MainSection.js | 40 + .../ClientApp/src/components/TodoApp.js | 136 + .../ClientApp/src/components/TodoItem.js | 63 + .../ClientApp/src/components/TodoList.js | 17 + .../src/components/TodoListFooter.js | 37 + .../ClientApp/src/components/TodoTextInput.js | 56 + .../__generated__/TodoApp_viewer.graphql.js | 71 + .../ClientApp/src/fetchQuery.js | 18 + src/GraphQL.Relay.Todo/ClientApp/src/index.js | 19 + .../src/mutations/AddTodoMutation.js | 25 + .../__generated__/AddTodoMutation.graphql.js | 30 + .../ClientApp/src/registerServiceWorker.js | 108 + .../ClientApp/src/setupProxy.js | 14 + .../ClientApp/src/stores/todo.js | 106 + .../Controllers/WeatherForecastController.cs | 38 + .../Database/TodoDatabase.cs | 15 +- .../GraphQL.Relay.Todo.csproj | 54 +- src/GraphQL.Relay.Todo/Pages/Error.cshtml | 26 + src/GraphQL.Relay.Todo/Pages/Error.cshtml.cs | 31 + .../Pages/_ViewImports.cshtml | 3 + src/GraphQL.Relay.Todo/Program.cs | 22 +- .../Properties/launchSettings.json | 28 +- src/GraphQL.Relay.Todo/README.md | 8 - src/GraphQL.Relay.Todo/Schema/Mutation.cs | 236 +- src/GraphQL.Relay.Todo/Schema/Query.cs | 10 + .../Schema/{Schema.cs => TodoSchema.cs} | 7 + src/GraphQL.Relay.Todo/SchemaWriter.cs | 6 + src/GraphQL.Relay.Todo/Startup.cs | 57 +- src/GraphQL.Relay.Todo/WeatherForecast.cs | 15 + .../appsettings.Development.json | 10 + src/GraphQL.Relay.Todo/appsettings.json | 10 + src/GraphQL.Relay.Todo/wwwroot/index.html | 6 + src/GraphQL.Relay.Todo/wwwroot/schema.json | 6 +- src/GraphQL.Relay/GraphQL.Relay.csproj | 2 +- src/GraphQL.Relay/Types/MutationInputs.cs | 29 - .../Types/MutationPayloadGraphType.cs | 63 - 55 files changed, 21093 insertions(+), 285 deletions(-) delete mode 100644 src/GraphQL.Relay.Todo/.babelrc create mode 100644 src/GraphQL.Relay.Todo/.gitignore create mode 100644 src/GraphQL.Relay.Todo/ClientApp/.env create mode 100644 src/GraphQL.Relay.Todo/ClientApp/.env.development create mode 100644 src/GraphQL.Relay.Todo/ClientApp/README.md delete mode 100644 src/GraphQL.Relay.Todo/ClientApp/components/TodoApp.js delete mode 100644 src/GraphQL.Relay.Todo/ClientApp/components/__generated__/TodoApp_viewer.graphql.js create mode 100644 src/GraphQL.Relay.Todo/ClientApp/package-lock.json create mode 100644 src/GraphQL.Relay.Todo/ClientApp/package.json create mode 100644 src/GraphQL.Relay.Todo/ClientApp/public/favicon.ico create mode 100644 src/GraphQL.Relay.Todo/ClientApp/public/index.html create mode 100644 src/GraphQL.Relay.Todo/ClientApp/public/manifest.json create mode 100644 src/GraphQL.Relay.Todo/ClientApp/src/App.js create mode 100644 src/GraphQL.Relay.Todo/ClientApp/src/App.test.js create mode 100644 src/GraphQL.Relay.Todo/ClientApp/src/RelayEnvironment.js create mode 100644 src/GraphQL.Relay.Todo/ClientApp/src/__generated__/AppQuery.graphql.js create mode 100644 src/GraphQL.Relay.Todo/ClientApp/src/components/Header.js create mode 100644 src/GraphQL.Relay.Todo/ClientApp/src/components/Link.js create mode 100644 src/GraphQL.Relay.Todo/ClientApp/src/components/MainSection.js create mode 100644 src/GraphQL.Relay.Todo/ClientApp/src/components/TodoApp.js create mode 100644 src/GraphQL.Relay.Todo/ClientApp/src/components/TodoItem.js create mode 100644 src/GraphQL.Relay.Todo/ClientApp/src/components/TodoList.js create mode 100644 src/GraphQL.Relay.Todo/ClientApp/src/components/TodoListFooter.js create mode 100644 src/GraphQL.Relay.Todo/ClientApp/src/components/TodoTextInput.js create mode 100644 src/GraphQL.Relay.Todo/ClientApp/src/components/__generated__/TodoApp_viewer.graphql.js create mode 100644 src/GraphQL.Relay.Todo/ClientApp/src/fetchQuery.js create mode 100644 src/GraphQL.Relay.Todo/ClientApp/src/index.js create mode 100644 src/GraphQL.Relay.Todo/ClientApp/src/mutations/AddTodoMutation.js rename src/GraphQL.Relay.Todo/ClientApp/{ => src}/mutations/__generated__/AddTodoMutation.graphql.js (88%) create mode 100644 src/GraphQL.Relay.Todo/ClientApp/src/registerServiceWorker.js create mode 100644 src/GraphQL.Relay.Todo/ClientApp/src/setupProxy.js create mode 100644 src/GraphQL.Relay.Todo/ClientApp/src/stores/todo.js create mode 100644 src/GraphQL.Relay.Todo/Controllers/WeatherForecastController.cs create mode 100644 src/GraphQL.Relay.Todo/Pages/Error.cshtml create mode 100644 src/GraphQL.Relay.Todo/Pages/Error.cshtml.cs create mode 100644 src/GraphQL.Relay.Todo/Pages/_ViewImports.cshtml delete mode 100644 src/GraphQL.Relay.Todo/README.md rename src/GraphQL.Relay.Todo/Schema/{Schema.cs => TodoSchema.cs} (52%) create mode 100644 src/GraphQL.Relay.Todo/WeatherForecast.cs create mode 100644 src/GraphQL.Relay.Todo/appsettings.Development.json create mode 100644 src/GraphQL.Relay.Todo/appsettings.json delete mode 100644 src/GraphQL.Relay/Types/MutationInputs.cs delete mode 100644 src/GraphQL.Relay/Types/MutationPayloadGraphType.cs diff --git a/GraphQL.Relay.sln b/GraphQL.Relay.sln index 279647d72..9e7a7c26e 100644 --- a/GraphQL.Relay.sln +++ b/GraphQL.Relay.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31205.134 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31423.177 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GraphQL.Relay", "src\GraphQL.Relay\GraphQL.Relay.csproj", "{46076F16-C4F7-4879-903D-70D75DD8B3EF}" EndProject @@ -8,8 +8,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GraphQL.Relay.Test", "src\G EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GraphQL.Relay.StarWars", "src\GraphQL.Relay.StarWars\GraphQL.Relay.StarWars.csproj", "{43F14E11-5D11-427C-B4F7-D68B2339E837}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GraphQL.Relay.Todo", "src\GraphQL.Relay.Todo\GraphQL.Relay.Todo.csproj", "{15AFC7EC-11E6-469F-87DF-D1E396463BE9}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{2F92B771-95CF-4FC3-AE9A-52E9273349F1}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{FA0A321D-0F73-478E-9B1D-495A96F4BF6D}" @@ -25,6 +23,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".Solution Items", ".Solutio src\Directory.Build.props = src\Directory.Build.props EndProjectSection EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GraphQL.Relay.Todo", "src\GraphQL.Relay.Todo\GraphQL.Relay.Todo.csproj", "{CA0C213A-8F2C-4238-A9B7-3D73A6A57CFA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -71,18 +71,18 @@ Global {43F14E11-5D11-427C-B4F7-D68B2339E837}.Release|x64.Build.0 = Release|Any CPU {43F14E11-5D11-427C-B4F7-D68B2339E837}.Release|x86.ActiveCfg = Release|Any CPU {43F14E11-5D11-427C-B4F7-D68B2339E837}.Release|x86.Build.0 = Release|Any CPU - {15AFC7EC-11E6-469F-87DF-D1E396463BE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {15AFC7EC-11E6-469F-87DF-D1E396463BE9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {15AFC7EC-11E6-469F-87DF-D1E396463BE9}.Debug|x64.ActiveCfg = Debug|Any CPU - {15AFC7EC-11E6-469F-87DF-D1E396463BE9}.Debug|x64.Build.0 = Debug|Any CPU - {15AFC7EC-11E6-469F-87DF-D1E396463BE9}.Debug|x86.ActiveCfg = Debug|Any CPU - {15AFC7EC-11E6-469F-87DF-D1E396463BE9}.Debug|x86.Build.0 = Debug|Any CPU - {15AFC7EC-11E6-469F-87DF-D1E396463BE9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {15AFC7EC-11E6-469F-87DF-D1E396463BE9}.Release|Any CPU.Build.0 = Release|Any CPU - {15AFC7EC-11E6-469F-87DF-D1E396463BE9}.Release|x64.ActiveCfg = Release|Any CPU - {15AFC7EC-11E6-469F-87DF-D1E396463BE9}.Release|x64.Build.0 = Release|Any CPU - {15AFC7EC-11E6-469F-87DF-D1E396463BE9}.Release|x86.ActiveCfg = Release|Any CPU - {15AFC7EC-11E6-469F-87DF-D1E396463BE9}.Release|x86.Build.0 = Release|Any CPU + {CA0C213A-8F2C-4238-A9B7-3D73A6A57CFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CA0C213A-8F2C-4238-A9B7-3D73A6A57CFA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CA0C213A-8F2C-4238-A9B7-3D73A6A57CFA}.Debug|x64.ActiveCfg = Debug|Any CPU + {CA0C213A-8F2C-4238-A9B7-3D73A6A57CFA}.Debug|x64.Build.0 = Debug|Any CPU + {CA0C213A-8F2C-4238-A9B7-3D73A6A57CFA}.Debug|x86.ActiveCfg = Debug|Any CPU + {CA0C213A-8F2C-4238-A9B7-3D73A6A57CFA}.Debug|x86.Build.0 = Debug|Any CPU + {CA0C213A-8F2C-4238-A9B7-3D73A6A57CFA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CA0C213A-8F2C-4238-A9B7-3D73A6A57CFA}.Release|Any CPU.Build.0 = Release|Any CPU + {CA0C213A-8F2C-4238-A9B7-3D73A6A57CFA}.Release|x64.ActiveCfg = Release|Any CPU + {CA0C213A-8F2C-4238-A9B7-3D73A6A57CFA}.Release|x64.Build.0 = Release|Any CPU + {CA0C213A-8F2C-4238-A9B7-3D73A6A57CFA}.Release|x86.ActiveCfg = Release|Any CPU + {CA0C213A-8F2C-4238-A9B7-3D73A6A57CFA}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/GraphQL.Relay.Todo/.babelrc b/src/GraphQL.Relay.Todo/.babelrc deleted file mode 100644 index d4afc3c21..000000000 --- a/src/GraphQL.Relay.Todo/.babelrc +++ /dev/null @@ -1,8 +0,0 @@ -{ - "presets": [ - "jason" - ], - "plugins": [ - "relay" - ] -} diff --git a/src/GraphQL.Relay.Todo/.gitignore b/src/GraphQL.Relay.Todo/.gitignore new file mode 100644 index 000000000..8f8b43bb1 --- /dev/null +++ b/src/GraphQL.Relay.Todo/.gitignore @@ -0,0 +1,232 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +bin/ +Bin/ +obj/ +Obj/ + +# Visual Studio 2015 cache/options directory +.vs/ +/wwwroot/dist/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Microsoft Azure ApplicationInsights config file +ApplicationInsights.config + +# Windows Store app package directory +AppPackages/ +BundleArtifacts/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +orleans.codegen.cs + +/node_modules + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe + +# FAKE - F# Make +.fake/ diff --git a/src/GraphQL.Relay.Todo/ClientApp/.env b/src/GraphQL.Relay.Todo/ClientApp/.env new file mode 100644 index 000000000..6ce384e5c --- /dev/null +++ b/src/GraphQL.Relay.Todo/ClientApp/.env @@ -0,0 +1 @@ +BROWSER=none diff --git a/src/GraphQL.Relay.Todo/ClientApp/.env.development b/src/GraphQL.Relay.Todo/ClientApp/.env.development new file mode 100644 index 000000000..2dcec8bed --- /dev/null +++ b/src/GraphQL.Relay.Todo/ClientApp/.env.development @@ -0,0 +1 @@ +PORT=5002 diff --git a/src/GraphQL.Relay.Todo/ClientApp/README.md b/src/GraphQL.Relay.Todo/ClientApp/README.md new file mode 100644 index 000000000..5a608cbdc --- /dev/null +++ b/src/GraphQL.Relay.Todo/ClientApp/README.md @@ -0,0 +1,2228 @@ +This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app). + +Below you will find some information on how to perform common tasks.
+You can find the most recent version of this guide [here](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md). + +## Table of Contents + +- [Updating to New Releases](#updating-to-new-releases) +- [Sending Feedback](#sending-feedback) +- [Folder Structure](#folder-structure) +- [Available Scripts](#available-scripts) + - [npm start](#npm-start) + - [npm test](#npm-test) + - [npm run build](#npm-run-build) + - [npm run eject](#npm-run-eject) +- [Supported Language Features and Polyfills](#supported-language-features-and-polyfills) +- [Syntax Highlighting in the Editor](#syntax-highlighting-in-the-editor) +- [Displaying Lint Output in the Editor](#displaying-lint-output-in-the-editor) +- [Debugging in the Editor](#debugging-in-the-editor) +- [Formatting Code Automatically](#formatting-code-automatically) +- [Changing the Page ``](#changing-the-page-title) +- [Installing a Dependency](#installing-a-dependency) +- [Importing a Component](#importing-a-component) +- [Code Splitting](#code-splitting) +- [Adding a Stylesheet](#adding-a-stylesheet) +- [Post-Processing CSS](#post-processing-css) +- [Adding a CSS Preprocessor (Sass, Less etc.)](#adding-a-css-preprocessor-sass-less-etc) +- [Adding Images, Fonts, and Files](#adding-images-fonts-and-files) +- [Using the `public` Folder](#using-the-public-folder) + - [Changing the HTML](#changing-the-html) + - [Adding Assets Outside of the Module System](#adding-assets-outside-of-the-module-system) + - [When to Use the `public` Folder](#when-to-use-the-public-folder) +- [Using Global Variables](#using-global-variables) +- [Adding Bootstrap](#adding-bootstrap) + - [Using a Custom Theme](#using-a-custom-theme) +- [Adding Flow](#adding-flow) +- [Adding Custom Environment Variables](#adding-custom-environment-variables) + - [Referencing Environment Variables in the HTML](#referencing-environment-variables-in-the-html) + - [Adding Temporary Environment Variables In Your Shell](#adding-temporary-environment-variables-in-your-shell) + - [Adding Development Environment Variables In `.env`](#adding-development-environment-variables-in-env) +- [Can I Use Decorators?](#can-i-use-decorators) +- [Integrating with an API Backend](#integrating-with-an-api-backend) + - [Node](#node) + - [Ruby on Rails](#ruby-on-rails) +- [Proxying API Requests in Development](#proxying-api-requests-in-development) + - ["Invalid Host Header" Errors After Configuring Proxy](#invalid-host-header-errors-after-configuring-proxy) + - [Configuring the Proxy Manually](#configuring-the-proxy-manually) + - [Configuring a WebSocket Proxy](#configuring-a-websocket-proxy) +- [Using HTTPS in Development](#using-https-in-development) +- [Generating Dynamic `<meta>` Tags on the Server](#generating-dynamic-meta-tags-on-the-server) +- [Pre-Rendering into Static HTML Files](#pre-rendering-into-static-html-files) +- [Injecting Data from the Server into the Page](#injecting-data-from-the-server-into-the-page) +- [Running Tests](#running-tests) + - [Filename Conventions](#filename-conventions) + - [Command Line Interface](#command-line-interface) + - [Version Control Integration](#version-control-integration) + - [Writing Tests](#writing-tests) + - [Testing Components](#testing-components) + - [Using Third Party Assertion Libraries](#using-third-party-assertion-libraries) + - [Initializing Test Environment](#initializing-test-environment) + - [Focusing and Excluding Tests](#focusing-and-excluding-tests) + - [Coverage Reporting](#coverage-reporting) + - [Continuous Integration](#continuous-integration) + - [Disabling jsdom](#disabling-jsdom) + - [Snapshot Testing](#snapshot-testing) + - [Editor Integration](#editor-integration) +- [Developing Components in Isolation](#developing-components-in-isolation) + - [Getting Started with Storybook](#getting-started-with-storybook) + - [Getting Started with Styleguidist](#getting-started-with-styleguidist) +- [Making a Progressive Web App](#making-a-progressive-web-app) + - [Opting Out of Caching](#opting-out-of-caching) + - [Offline-First Considerations](#offline-first-considerations) + - [Progressive Web App Metadata](#progressive-web-app-metadata) +- [Analyzing the Bundle Size](#analyzing-the-bundle-size) +- [Deployment](#deployment) + - [Static Server](#static-server) + - [Other Solutions](#other-solutions) + - [Serving Apps with Client-Side Routing](#serving-apps-with-client-side-routing) + - [Building for Relative Paths](#building-for-relative-paths) + - [Azure](#azure) + - [Firebase](#firebase) + - [GitHub Pages](#github-pages) + - [Heroku](#heroku) + - [Netlify](#netlify) + - [Now](#now) + - [S3 and CloudFront](#s3-and-cloudfront) + - [Surge](#surge) +- [Advanced Configuration](#advanced-configuration) +- [Troubleshooting](#troubleshooting) + - [`npm start` doesn’t detect changes](#npm-start-doesnt-detect-changes) + - [`npm test` hangs on macOS Sierra](#npm-test-hangs-on-macos-sierra) + - [`npm run build` exits too early](#npm-run-build-exits-too-early) + - [`npm run build` fails on Heroku](#npm-run-build-fails-on-heroku) + - [`npm run build` fails to minify](#npm-run-build-fails-to-minify) + - [Moment.js locales are missing](#momentjs-locales-are-missing) +- [Something Missing?](#something-missing) + +## Updating to New Releases + +Create React App is divided into two packages: + +* `create-react-app` is a global command-line utility that you use to create new projects. +* `react-scripts` is a development dependency in the generated projects (including this one). + +You almost never need to update `create-react-app` itself: it delegates all the setup to `react-scripts`. + +When you run `create-react-app`, it always creates the project with the latest version of `react-scripts` so you’ll get all the new features and improvements in newly created apps automatically. + +To update an existing project to a new version of `react-scripts`, [open the changelog](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md), find the version you’re currently on (check `package.json` in this folder if you’re not sure), and apply the migration instructions for the newer versions. + +In most cases bumping the `react-scripts` version in `package.json` and running `npm install` in this folder should be enough, but it’s good to consult the [changelog](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md) for potential breaking changes. + +We commit to keeping the breaking changes minimal so you can upgrade `react-scripts` painlessly. + +## Sending Feedback + +We are always open to [your feedback](https://github.com/facebookincubator/create-react-app/issues). + +## Folder Structure + +After creation, your project should look like this: + +``` +my-app/ + README.md + node_modules/ + package.json + public/ + index.html + favicon.ico + src/ + App.css + App.js + App.test.js + index.css + index.js + logo.svg +``` + +For the project to build, **these files must exist with exact filenames**: + +* `public/index.html` is the page template; +* `src/index.js` is the JavaScript entry point. + +You can delete or rename the other files. + +You may create subdirectories inside `src`. For faster rebuilds, only files inside `src` are processed by Webpack.<br> +You need to **put any JS and CSS files inside `src`**, otherwise Webpack won’t see them. + +Only files inside `public` can be used from `public/index.html`.<br> +Read instructions below for using assets from JavaScript and HTML. + +You can, however, create more top-level directories.<br> +They will not be included in the production build so you can use them for things like documentation. + +## Available Scripts + +In the project directory, you can run: + +### `npm start` + +Runs the app in the development mode.<br> +Open [http://localhost:3000](http://localhost:3000) to view it in the browser. + +The page will reload if you make edits.<br> +You will also see any lint errors in the console. + +### `npm test` + +Launches the test runner in the interactive watch mode.<br> +See the section about [running tests](#running-tests) for more information. + +### `npm run build` + +Builds the app for production to the `build` folder.<br> +It correctly bundles React in production mode and optimizes the build for the best performance. + +The build is minified and the filenames include the hashes.<br> +Your app is ready to be deployed! + +See the section about [deployment](#deployment) for more information. + +### `npm run eject` + +**Note: this is a one-way operation. Once you `eject`, you can’t go back!** + +If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. + +Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. + +You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. + +## Supported Language Features and Polyfills + +This project supports a superset of the latest JavaScript standard.<br> +In addition to [ES6](https://github.com/lukehoban/es6features) syntax features, it also supports: + +* [Exponentiation Operator](https://github.com/rwaldron/exponentiation-operator) (ES2016). +* [Async/await](https://github.com/tc39/ecmascript-asyncawait) (ES2017). +* [Object Rest/Spread Properties](https://github.com/sebmarkbage/ecmascript-rest-spread) (stage 3 proposal). +* [Dynamic import()](https://github.com/tc39/proposal-dynamic-import) (stage 3 proposal) +* [Class Fields and Static Properties](https://github.com/tc39/proposal-class-public-fields) (part of stage 3 proposal). +* [JSX](https://facebook.github.io/react/docs/introducing-jsx.html) and [Flow](https://flowtype.org/) syntax. + +Learn more about [different proposal stages](https://babeljs.io/docs/plugins/#presets-stage-x-experimental-presets-). + +While we recommend using experimental proposals with some caution, Facebook heavily uses these features in the product code, so we intend to provide [codemods](https://medium.com/@cpojer/effective-javascript-codemods-5a6686bb46fb) if any of these proposals change in the future. + +Note that **the project only includes a few ES6 [polyfills](https://en.wikipedia.org/wiki/Polyfill)**: + +* [`Object.assign()`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) via [`object-assign`](https://github.com/sindresorhus/object-assign). +* [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) via [`promise`](https://github.com/then/promise). +* [`fetch()`](https://developer.mozilla.org/en/docs/Web/API/Fetch_API) via [`whatwg-fetch`](https://github.com/github/fetch). + +If you use any other ES6+ features that need **runtime support** (such as `Array.from()` or `Symbol`), make sure you are including the appropriate polyfills manually, or that the browsers you are targeting already support them. + +## Syntax Highlighting in the Editor + +To configure the syntax highlighting in your favorite text editor, head to the [relevant Babel documentation page](https://babeljs.io/docs/editors) and follow the instructions. Some of the most popular editors are covered. + +## Displaying Lint Output in the Editor + +>Note: this feature is available with `react-scripts@0.2.0` and higher.<br> +>It also only works with npm 3 or higher. + +Some editors, including Sublime Text, Atom, and Visual Studio Code, provide plugins for ESLint. + +They are not required for linting. You should see the linter output right in your terminal as well as the browser console. However, if you prefer the lint results to appear right in your editor, there are some extra steps you can do. + +You would need to install an ESLint plugin for your editor first. Then, add a file called `.eslintrc` to the project root: + +```js +{ + "extends": "react-app" +} +``` + +Now your editor should report the linting warnings. + +Note that even if you edit your `.eslintrc` file further, these changes will **only affect the editor integration**. They won’t affect the terminal and in-browser lint output. This is because Create React App intentionally provides a minimal set of rules that find common mistakes. + +If you want to enforce a coding style for your project, consider using [Prettier](https://github.com/jlongster/prettier) instead of ESLint style rules. + +## Debugging in the Editor + +**This feature is currently only supported by [Visual Studio Code](https://code.visualstudio.com) and [WebStorm](https://www.jetbrains.com/webstorm/).** + +Visual Studio Code and WebStorm support debugging out of the box with Create React App. This enables you as a developer to write and debug your React code without leaving the editor, and most importantly it enables you to have a continuous development workflow, where context switching is minimal, as you don’t have to switch between tools. + +### Visual Studio Code + +You would need to have the latest version of [VS Code](https://code.visualstudio.com) and VS Code [Chrome Debugger Extension](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome) installed. + +Then add the block below to your `launch.json` file and put it inside the `.vscode` folder in your app’s root directory. + +```json +{ + "version": "0.2.0", + "configurations": [{ + "name": "Chrome", + "type": "chrome", + "request": "launch", + "url": "http://localhost:3000", + "webRoot": "${workspaceRoot}/src", + "sourceMapPathOverrides": { + "webpack:///src/*": "${webRoot}/*" + } + }] +} +``` +>Note: the URL may be different if you've made adjustments via the [HOST or PORT environment variables](#advanced-configuration). + +Start your app by running `npm start`, and start debugging in VS Code by pressing `F5` or by clicking the green debug icon. You can now write code, set breakpoints, make changes to the code, and debug your newly modified code—all from your editor. + +Having problems with VS Code Debugging? Please see their [troubleshooting guide](https://github.com/Microsoft/vscode-chrome-debug/blob/master/README.md#troubleshooting). + +### WebStorm + +You would need to have [WebStorm](https://www.jetbrains.com/webstorm/) and [JetBrains IDE Support](https://chrome.google.com/webstore/detail/jetbrains-ide-support/hmhgeddbohgjknpmjagkdomcpobmllji) Chrome extension installed. + +In the WebStorm menu `Run` select `Edit Configurations...`. Then click `+` and select `JavaScript Debug`. Paste `http://localhost:3000` into the URL field and save the configuration. + +>Note: the URL may be different if you've made adjustments via the [HOST or PORT environment variables](#advanced-configuration). + +Start your app by running `npm start`, then press `^D` on macOS or `F9` on Windows and Linux or click the green debug icon to start debugging in WebStorm. + +The same way you can debug your application in IntelliJ IDEA Ultimate, PhpStorm, PyCharm Pro, and RubyMine. + +## Formatting Code Automatically + +Prettier is an opinionated code formatter with support for JavaScript, CSS and JSON. With Prettier you can format the code you write automatically to ensure a code style within your project. See the [Prettier's GitHub page](https://github.com/prettier/prettier) for more information, and look at this [page to see it in action](https://prettier.github.io/prettier/). + +To format our code whenever we make a commit in git, we need to install the following dependencies: + +```sh +npm install --save husky lint-staged prettier +``` + +Alternatively you may use `yarn`: + +```sh +yarn add husky lint-staged prettier +``` + +* `husky` makes it easy to use githooks as if they are npm scripts. +* `lint-staged` allows us to run scripts on staged files in git. See this [blog post about lint-staged to learn more about it](https://medium.com/@okonetchnikov/make-linting-great-again-f3890e1ad6b8). +* `prettier` is the JavaScript formatter we will run before commits. + +Now we can make sure every file is formatted correctly by adding a few lines to the `package.json` in the project root. + +Add the following line to `scripts` section: + +```diff + "scripts": { ++ "precommit": "lint-staged", + "start": "react-scripts start", + "build": "react-scripts build", +``` + +Next we add a 'lint-staged' field to the `package.json`, for example: + +```diff + "dependencies": { + // ... + }, ++ "lint-staged": { ++ "src/**/*.{js,jsx,json,css}": [ ++ "prettier --single-quote --write", ++ "git add" ++ ] ++ }, + "scripts": { +``` + +Now, whenever you make a commit, Prettier will format the changed files automatically. You can also run `./node_modules/.bin/prettier --single-quote --write "src/**/*.{js,jsx}"` to format your entire project for the first time. + +Next you might want to integrate Prettier in your favorite editor. Read the section on [Editor Integration](https://github.com/prettier/prettier#editor-integration) on the Prettier GitHub page. + +## Changing the Page `<title>` + +You can find the source HTML file in the `public` folder of the generated project. You may edit the `<title>` tag in it to change the title from “React App” to anything else. + +Note that normally you wouldn’t edit files in the `public` folder very often. For example, [adding a stylesheet](#adding-a-stylesheet) is done without touching the HTML. + +If you need to dynamically update the page title based on the content, you can use the browser [`document.title`](https://developer.mozilla.org/en-US/docs/Web/API/Document/title) API. For more complex scenarios when you want to change the title from React components, you can use [React Helmet](https://github.com/nfl/react-helmet), a third party library. + +If you use a custom server for your app in production and want to modify the title before it gets sent to the browser, you can follow advice in [this section](#generating-dynamic-meta-tags-on-the-server). Alternatively, you can pre-build each page as a static HTML file which then loads the JavaScript bundle, which is covered [here](#pre-rendering-into-static-html-files). + +## Installing a Dependency + +The generated project includes React and ReactDOM as dependencies. It also includes a set of scripts used by Create React App as a development dependency. You may install other dependencies (for example, React Router) with `npm`: + +```sh +npm install --save react-router +``` + +Alternatively you may use `yarn`: + +```sh +yarn add react-router +``` + +This works for any library, not just `react-router`. + +## Importing a Component + +This project setup supports ES6 modules thanks to Babel.<br> +While you can still use `require()` and `module.exports`, we encourage you to use [`import` and `export`](http://exploringjs.com/es6/ch_modules.html) instead. + +For example: + +### `Button.js` + +```js +import React, { Component } from 'react'; + +class Button extends Component { + render() { + // ... + } +} + +export default Button; // Don’t forget to use export default! +``` + +### `DangerButton.js` + + +```js +import React, { Component } from 'react'; +import Button from './Button'; // Import a component from another file + +class DangerButton extends Component { + render() { + return <Button color="red" />; + } +} + +export default DangerButton; +``` + +Be aware of the [difference between default and named exports](http://stackoverflow.com/questions/36795819/react-native-es-6-when-should-i-use-curly-braces-for-import/36796281#36796281). It is a common source of mistakes. + +We suggest that you stick to using default imports and exports when a module only exports a single thing (for example, a component). That’s what you get when you use `export default Button` and `import Button from './Button'`. + +Named exports are useful for utility modules that export several functions. A module may have at most one default export and as many named exports as you like. + +Learn more about ES6 modules: + +* [When to use the curly braces?](http://stackoverflow.com/questions/36795819/react-native-es-6-when-should-i-use-curly-braces-for-import/36796281#36796281) +* [Exploring ES6: Modules](http://exploringjs.com/es6/ch_modules.html) +* [Understanding ES6: Modules](https://leanpub.com/understandinges6/read#leanpub-auto-encapsulating-code-with-modules) + +## Code Splitting + +Instead of downloading the entire app before users can use it, code splitting allows you to split your code into small chunks which you can then load on demand. + +This project setup supports code splitting via [dynamic `import()`](http://2ality.com/2017/01/import-operator.html#loading-code-on-demand). Its [proposal](https://github.com/tc39/proposal-dynamic-import) is in stage 3. The `import()` function-like form takes the module name as an argument and returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) which always resolves to the namespace object of the module. + +Here is an example: + +### `moduleA.js` + +```js +const moduleA = 'Hello'; + +export { moduleA }; +``` +### `App.js` + +```js +import React, { Component } from 'react'; + +class App extends Component { + handleClick = () => { + import('./moduleA') + .then(({ moduleA }) => { + // Use moduleA + }) + .catch(err => { + // Handle failure + }); + }; + + render() { + return ( + <div> + <button onClick={this.handleClick}>Load</button> + </div> + ); + } +} + +export default App; +``` + +This will make `moduleA.js` and all its unique dependencies as a separate chunk that only loads after the user clicks the 'Load' button. + +You can also use it with `async` / `await` syntax if you prefer it. + +### With React Router + +If you are using React Router check out [this tutorial](http://serverless-stack.com/chapters/code-splitting-in-create-react-app.html) on how to use code splitting with it. You can find the companion GitHub repository [here](https://github.com/AnomalyInnovations/serverless-stack-demo-client/tree/code-splitting-in-create-react-app). + +## Adding a Stylesheet + +This project setup uses [Webpack](https://webpack.js.org/) for handling all assets. Webpack offers a custom way of “extending” the concept of `import` beyond JavaScript. To express that a JavaScript file depends on a CSS file, you need to **import the CSS from the JavaScript file**: + +### `Button.css` + +```css +.Button { + padding: 20px; +} +``` + +### `Button.js` + +```js +import React, { Component } from 'react'; +import './Button.css'; // Tell Webpack that Button.js uses these styles + +class Button extends Component { + render() { + // You can use them as regular CSS styles + return <div className="Button" />; + } +} +``` + +**This is not required for React** but many people find this feature convenient. You can read about the benefits of this approach [here](https://medium.com/seek-ui-engineering/block-element-modifying-your-javascript-components-d7f99fcab52b). However you should be aware that this makes your code less portable to other build tools and environments than Webpack. + +In development, expressing dependencies this way allows your styles to be reloaded on the fly as you edit them. In production, all CSS files will be concatenated into a single minified `.css` file in the build output. + +If you are concerned about using Webpack-specific semantics, you can put all your CSS right into `src/index.css`. It would still be imported from `src/index.js`, but you could always remove that import if you later migrate to a different build tool. + +## Post-Processing CSS + +This project setup minifies your CSS and adds vendor prefixes to it automatically through [Autoprefixer](https://github.com/postcss/autoprefixer) so you don’t need to worry about it. + +For example, this: + +```css +.App { + display: flex; + flex-direction: row; + align-items: center; +} +``` + +becomes this: + +```css +.App { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: horizontal; + -webkit-box-direction: normal; + -ms-flex-direction: row; + flex-direction: row; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} +``` + +If you need to disable autoprefixing for some reason, [follow this section](https://github.com/postcss/autoprefixer#disabling). + +## Adding a CSS Preprocessor (Sass, Less etc.) + +Generally, we recommend that you don’t reuse the same CSS classes across different components. For example, instead of using a `.Button` CSS class in `<AcceptButton>` and `<RejectButton>` components, we recommend creating a `<Button>` component with its own `.Button` styles, that both `<AcceptButton>` and `<RejectButton>` can render (but [not inherit](https://facebook.github.io/react/docs/composition-vs-inheritance.html)). + +Following this rule often makes CSS preprocessors less useful, as features like mixins and nesting are replaced by component composition. You can, however, integrate a CSS preprocessor if you find it valuable. In this walkthrough, we will be using Sass, but you can also use Less, or another alternative. + +First, let’s install the command-line interface for Sass: + +```sh +npm install --save node-sass-chokidar +``` + +Alternatively you may use `yarn`: + +```sh +yarn add node-sass-chokidar +``` + +Then in `package.json`, add the following lines to `scripts`: + +```diff + "scripts": { ++ "build-css": "node-sass-chokidar src/ -o src/", ++ "watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive", + "start": "react-scripts start", + "build": "react-scripts build", + "test": "react-scripts test --env=jsdom", +``` + +>Note: To use a different preprocessor, replace `build-css` and `watch-css` commands according to your preprocessor’s documentation. + +Now you can rename `src/App.css` to `src/App.scss` and run `npm run watch-css`. The watcher will find every Sass file in `src` subdirectories, and create a corresponding CSS file next to it, in our case overwriting `src/App.css`. Since `src/App.js` still imports `src/App.css`, the styles become a part of your application. You can now edit `src/App.scss`, and `src/App.css` will be regenerated. + +To share variables between Sass files, you can use Sass imports. For example, `src/App.scss` and other component style files could include `@import "./shared.scss";` with variable definitions. + +To enable importing files without using relative paths, you can add the `--include-path` option to the command in `package.json`. + +``` +"build-css": "node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/", +"watch-css": "npm run build-css && node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/ --watch --recursive", +``` + +This will allow you to do imports like + +```scss +@import 'styles/_colors.scss'; // assuming a styles directory under src/ +@import 'nprogress/nprogress'; // importing a css file from the nprogress node module +``` + +At this point you might want to remove all CSS files from the source control, and add `src/**/*.css` to your `.gitignore` file. It is generally a good practice to keep the build products outside of the source control. + +As a final step, you may find it convenient to run `watch-css` automatically with `npm start`, and run `build-css` as a part of `npm run build`. You can use the `&&` operator to execute two scripts sequentially. However, there is no cross-platform way to run two scripts in parallel, so we will install a package for this: + +```sh +npm install --save npm-run-all +``` + +Alternatively you may use `yarn`: + +```sh +yarn add npm-run-all +``` + +Then we can change `start` and `build` scripts to include the CSS preprocessor commands: + +```diff + "scripts": { + "build-css": "node-sass-chokidar src/ -o src/", + "watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive", +- "start": "react-scripts start", +- "build": "react-scripts build", ++ "start-js": "react-scripts start", ++ "start": "npm-run-all -p watch-css start-js", ++ "build-js": "react-scripts build", ++ "build": "npm-run-all build-css build-js", + "test": "react-scripts test --env=jsdom", + "eject": "react-scripts eject" + } +``` + +Now running `npm start` and `npm run build` also builds Sass files. + +**Why `node-sass-chokidar`?** + +`node-sass` has been reported as having the following issues: + +- `node-sass --watch` has been reported to have *performance issues* in certain conditions when used in a virtual machine or with docker. + +- Infinite styles compiling [#1939](https://github.com/facebookincubator/create-react-app/issues/1939) + +- `node-sass` has been reported as having issues with detecting new files in a directory [#1891](https://github.com/sass/node-sass/issues/1891) + + `node-sass-chokidar` is used here as it addresses these issues. + +## Adding Images, Fonts, and Files + +With Webpack, using static assets like images and fonts works similarly to CSS. + +You can **`import` a file right in a JavaScript module**. This tells Webpack to include that file in the bundle. Unlike CSS imports, importing a file gives you a string value. This value is the final path you can reference in your code, e.g. as the `src` attribute of an image or the `href` of a link to a PDF. + +To reduce the number of requests to the server, importing images that are less than 10,000 bytes returns a [data URI](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) instead of a path. This applies to the following file extensions: bmp, gif, jpg, jpeg, and png. SVG files are excluded due to [#1153](https://github.com/facebookincubator/create-react-app/issues/1153). + +Here is an example: + +```js +import React from 'react'; +import logo from './logo.png'; // Tell Webpack this JS file uses this image + +console.log(logo); // /logo.84287d09.png + +function Header() { + // Import result is the URL of your image + return <img src={logo} alt="Logo" />; +} + +export default Header; +``` + +This ensures that when the project is built, Webpack will correctly move the images into the build folder, and provide us with correct paths. + +This works in CSS too: + +```css +.Logo { + background-image: url(./logo.png); +} +``` + +Webpack finds all relative module references in CSS (they start with `./`) and replaces them with the final paths from the compiled bundle. If you make a typo or accidentally delete an important file, you will see a compilation error, just like when you import a non-existent JavaScript module. The final filenames in the compiled bundle are generated by Webpack from content hashes. If the file content changes in the future, Webpack will give it a different name in production so you don’t need to worry about long-term caching of assets. + +Please be advised that this is also a custom feature of Webpack. + +**It is not required for React** but many people enjoy it (and React Native uses a similar mechanism for images).<br> +An alternative way of handling static assets is described in the next section. + +## Using the `public` Folder + +>Note: this feature is available with `react-scripts@0.5.0` and higher. + +### Changing the HTML + +The `public` folder contains the HTML file so you can tweak it, for example, to [set the page title](#changing-the-page-title). +The `<script>` tag with the compiled code will be added to it automatically during the build process. + +### Adding Assets Outside of the Module System + +You can also add other assets to the `public` folder. + +Note that we normally encourage you to `import` assets in JavaScript files instead. +For example, see the sections on [adding a stylesheet](#adding-a-stylesheet) and [adding images and fonts](#adding-images-fonts-and-files). +This mechanism provides a number of benefits: + +* Scripts and stylesheets get minified and bundled together to avoid extra network requests. +* Missing files cause compilation errors instead of 404 errors for your users. +* Result filenames include content hashes so you don’t need to worry about browsers caching their old versions. + +However there is an **escape hatch** that you can use to add an asset outside of the module system. + +If you put a file into the `public` folder, it will **not** be processed by Webpack. Instead it will be copied into the build folder untouched. To reference assets in the `public` folder, you need to use a special variable called `PUBLIC_URL`. + +Inside `index.html`, you can use it like this: + +```html +<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"> +``` + +Only files inside the `public` folder will be accessible by `%PUBLIC_URL%` prefix. If you need to use a file from `src` or `node_modules`, you’ll have to copy it there to explicitly specify your intention to make this file a part of the build. + +When you run `npm run build`, Create React App will substitute `%PUBLIC_URL%` with a correct absolute path so your project works even if you use client-side routing or host it at a non-root URL. + +In JavaScript code, you can use `process.env.PUBLIC_URL` for similar purposes: + +```js +render() { + // Note: this is an escape hatch and should be used sparingly! + // Normally we recommend using `import` for getting asset URLs + // as described in “Adding Images and Fonts” above this section. + return <img src={process.env.PUBLIC_URL + '/img/logo.png'} />; +} +``` + +Keep in mind the downsides of this approach: + +* None of the files in `public` folder get post-processed or minified. +* Missing files will not be called at compilation time, and will cause 404 errors for your users. +* Result filenames won’t include content hashes so you’ll need to add query arguments or rename them every time they change. + +### When to Use the `public` Folder + +Normally we recommend importing [stylesheets](#adding-a-stylesheet), [images, and fonts](#adding-images-fonts-and-files) from JavaScript. +The `public` folder is useful as a workaround for a number of less common cases: + +* You need a file with a specific name in the build output, such as [`manifest.webmanifest`](https://developer.mozilla.org/en-US/docs/Web/Manifest). +* You have thousands of images and need to dynamically reference their paths. +* You want to include a small script like [`pace.js`](http://github.hubspot.com/pace/docs/welcome/) outside of the bundled code. +* Some library may be incompatible with Webpack and you have no other option but to include it as a `<script>` tag. + +Note that if you add a `<script>` that declares global variables, you also need to read the next section on using them. + +## Using Global Variables + +When you include a script in the HTML file that defines global variables and try to use one of these variables in the code, the linter will complain because it cannot see the definition of the variable. + +You can avoid this by reading the global variable explicitly from the `window` object, for example: + +```js +const $ = window.$; +``` + +This makes it obvious you are using a global variable intentionally rather than because of a typo. + +Alternatively, you can force the linter to ignore any line by adding `// eslint-disable-line` after it. + +## Adding Bootstrap + +You don’t have to use [Reactstrap](https://reactstrap.github.io/) together with React but it is a popular library for integrating Bootstrap with React apps. If you need it, you can integrate it with Create React App by following these steps: + +Install Reactstrap and Bootstrap from npm. React Bootstrap does not include Bootstrap CSS so this needs to be installed as well: + +```sh +npm install --save reactstrap bootstrap@4 +``` + +Alternatively you may use `yarn`: + +```sh +yarn add reactstrap bootstrap@4 +``` + +Import Bootstrap CSS and optionally Bootstrap theme CSS in the beginning of your ```src/index.js``` file: + +```js +import 'bootstrap/dist/css/bootstrap.css'; +// Put any other imports below so that CSS from your +// components takes precedence over default styles. +``` + +Import required React Bootstrap components within ```src/App.js``` file or your custom component files: + +```js +import { Navbar, Button } from 'reactstrap'; +``` + +Now you are ready to use the imported React Bootstrap components within your component hierarchy defined in the render method. Here is an example [`App.js`](https://gist.githubusercontent.com/gaearon/85d8c067f6af1e56277c82d19fd4da7b/raw/6158dd991b67284e9fc8d70b9d973efe87659d72/App.js) redone using React Bootstrap. + +### Using a Custom Theme + +Sometimes you might need to tweak the visual styles of Bootstrap (or equivalent package).<br> +We suggest the following approach: + +* Create a new package that depends on the package you wish to customize, e.g. Bootstrap. +* Add the necessary build steps to tweak the theme, and publish your package on npm. +* Install your own theme npm package as a dependency of your app. + +Here is an example of adding a [customized Bootstrap](https://medium.com/@tacomanator/customizing-create-react-app-aa9ffb88165) that follows these steps. + +## Adding Flow + +Flow is a static type checker that helps you write code with fewer bugs. Check out this [introduction to using static types in JavaScript](https://medium.com/@preethikasireddy/why-use-static-types-in-javascript-part-1-8382da1e0adb) if you are new to this concept. + +Recent versions of [Flow](http://flowtype.org/) work with Create React App projects out of the box. + +To add Flow to a Create React App project, follow these steps: + +1. Run `npm install --save flow-bin` (or `yarn add flow-bin`). +2. Add `"flow": "flow"` to the `scripts` section of your `package.json`. +3. Run `npm run flow init` (or `yarn flow init`) to create a [`.flowconfig` file](https://flowtype.org/docs/advanced-configuration.html) in the root directory. +4. Add `// @flow` to any files you want to type check (for example, to `src/App.js`). + +Now you can run `npm run flow` (or `yarn flow`) to check the files for type errors. +You can optionally use an IDE like [Nuclide](https://nuclide.io/docs/languages/flow/) for a better integrated experience. +In the future we plan to integrate it into Create React App even more closely. + +To learn more about Flow, check out [its documentation](https://flowtype.org/). + +## Adding Custom Environment Variables + +>Note: this feature is available with `react-scripts@0.2.3` and higher. + +Your project can consume variables declared in your environment as if they were declared locally in your JS files. By +default you will have `NODE_ENV` defined for you, and any other environment variables starting with +`REACT_APP_`. + +**The environment variables are embedded during the build time**. Since Create React App produces a static HTML/CSS/JS bundle, it can’t possibly read them at runtime. To read them at runtime, you would need to load HTML into memory on the server and replace placeholders in runtime, just like [described here](#injecting-data-from-the-server-into-the-page). Alternatively you can rebuild the app on the server anytime you change them. + +>Note: You must create custom environment variables beginning with `REACT_APP_`. Any other variables except `NODE_ENV` will be ignored to avoid accidentally [exposing a private key on the machine that could have the same name](https://github.com/facebookincubator/create-react-app/issues/865#issuecomment-252199527). Changing any environment variables will require you to restart the development server if it is running. + +These environment variables will be defined for you on `process.env`. For example, having an environment +variable named `REACT_APP_SECRET_CODE` will be exposed in your JS as `process.env.REACT_APP_SECRET_CODE`. + +There is also a special built-in environment variable called `NODE_ENV`. You can read it from `process.env.NODE_ENV`. When you run `npm start`, it is always equal to `'development'`, when you run `npm test` it is always equal to `'test'`, and when you run `npm run build` to make a production bundle, it is always equal to `'production'`. **You cannot override `NODE_ENV` manually.** This prevents developers from accidentally deploying a slow development build to production. + +These environment variables can be useful for displaying information conditionally based on where the project is +deployed or consuming sensitive data that lives outside of version control. + +First, you need to have environment variables defined. For example, let’s say you wanted to consume a secret defined +in the environment inside a `<form>`: + +```jsx +render() { + return ( + <div> + <small>You are running this application in <b>{process.env.NODE_ENV}</b> mode.</small> + <form> + <input type="hidden" defaultValue={process.env.REACT_APP_SECRET_CODE} /> + </form> + </div> + ); +} +``` + +During the build, `process.env.REACT_APP_SECRET_CODE` will be replaced with the current value of the `REACT_APP_SECRET_CODE` environment variable. Remember that the `NODE_ENV` variable will be set for you automatically. + +When you load the app in the browser and inspect the `<input>`, you will see its value set to `abcdef`, and the bold text will show the environment provided when using `npm start`: + +```html +<div> + <small>You are running this application in <b>development</b> mode.</small> + <form> + <input type="hidden" value="abcdef" /> + </form> +</div> +``` + +The above form is looking for a variable called `REACT_APP_SECRET_CODE` from the environment. In order to consume this +value, we need to have it defined in the environment. This can be done using two ways: either in your shell or in +a `.env` file. Both of these ways are described in the next few sections. + +Having access to the `NODE_ENV` is also useful for performing actions conditionally: + +```js +if (process.env.NODE_ENV !== 'production') { + analytics.disable(); +} +``` + +When you compile the app with `npm run build`, the minification step will strip out this condition, and the resulting bundle will be smaller. + +### Referencing Environment Variables in the HTML + +>Note: this feature is available with `react-scripts@0.9.0` and higher. + +You can also access the environment variables starting with `REACT_APP_` in the `public/index.html`. For example: + +```html +<title>%REACT_APP_WEBSITE_NAME% +``` + +Note that the caveats from the above section apply: + +* Apart from a few built-in variables (`NODE_ENV` and `PUBLIC_URL`), variable names must start with `REACT_APP_` to work. +* The environment variables are injected at build time. If you need to inject them at runtime, [follow this approach instead](#generating-dynamic-meta-tags-on-the-server). + +### Adding Temporary Environment Variables In Your Shell + +Defining environment variables can vary between OSes. It’s also important to know that this manner is temporary for the +life of the shell session. + +#### Windows (cmd.exe) + +```cmd +set REACT_APP_SECRET_CODE=abcdef&&npm start +``` + +(Note: the lack of whitespace is intentional.) + +#### Linux, macOS (Bash) + +```bash +REACT_APP_SECRET_CODE=abcdef npm start +``` + +### Adding Development Environment Variables In `.env` + +>Note: this feature is available with `react-scripts@0.5.0` and higher. + +To define permanent environment variables, create a file called `.env` in the root of your project: + +``` +REACT_APP_SECRET_CODE=abcdef +``` + +`.env` files **should be** checked into source control (with the exclusion of `.env*.local`). + +#### What other `.env` files can be used? + +>Note: this feature is **available with `react-scripts@1.0.0` and higher**. + +* `.env`: Default. +* `.env.local`: Local overrides. **This file is loaded for all environments except test.** +* `.env.development`, `.env.test`, `.env.production`: Environment-specific settings. +* `.env.development.local`, `.env.test.local`, `.env.production.local`: Local overrides of environment-specific settings. + +Files on the left have more priority than files on the right: + +* `npm start`: `.env.development.local`, `.env.development`, `.env.local`, `.env` +* `npm run build`: `.env.production.local`, `.env.production`, `.env.local`, `.env` +* `npm test`: `.env.test.local`, `.env.test`, `.env` (note `.env.local` is missing) + +These variables will act as the defaults if the machine does not explicitly set them.
+Please refer to the [dotenv documentation](https://github.com/motdotla/dotenv) for more details. + +>Note: If you are defining environment variables for development, your CI and/or hosting platform will most likely need +these defined as well. Consult their documentation how to do this. For example, see the documentation for [Travis CI](https://docs.travis-ci.com/user/environment-variables/) or [Heroku](https://devcenter.heroku.com/articles/config-vars). + +## Can I Use Decorators? + +Many popular libraries use [decorators](https://medium.com/google-developers/exploring-es7-decorators-76ecb65fb841) in their documentation.
+Create React App doesn’t support decorator syntax at the moment because: + +* It is an experimental proposal and is subject to change. +* The current specification version is not officially supported by Babel. +* If the specification changes, we won’t be able to write a codemod because we don’t use them internally at Facebook. + +However in many cases you can rewrite decorator-based code without decorators just as fine.
+Please refer to these two threads for reference: + +* [#214](https://github.com/facebookincubator/create-react-app/issues/214) +* [#411](https://github.com/facebookincubator/create-react-app/issues/411) + +Create React App will add decorator support when the specification advances to a stable stage. + +## Integrating with an API Backend + +These tutorials will help you to integrate your app with an API backend running on another port, +using `fetch()` to access it. + +### Node +Check out [this tutorial](https://www.fullstackreact.com/articles/using-create-react-app-with-a-server/). +You can find the companion GitHub repository [here](https://github.com/fullstackreact/food-lookup-demo). + +### Ruby on Rails + +Check out [this tutorial](https://www.fullstackreact.com/articles/how-to-get-create-react-app-to-work-with-your-rails-api/). +You can find the companion GitHub repository [here](https://github.com/fullstackreact/food-lookup-demo-rails). + +## Proxying API Requests in Development + +>Note: this feature is available with `react-scripts@0.2.3` and higher. + +People often serve the front-end React app from the same host and port as their backend implementation.
+For example, a production setup might look like this after the app is deployed: + +``` +/ - static server returns index.html with React app +/todos - static server returns index.html with React app +/api/todos - server handles any /api/* requests using the backend implementation +``` + +Such setup is **not** required. However, if you **do** have a setup like this, it is convenient to write requests like `fetch('/api/todos')` without worrying about redirecting them to another host or port during development. + +To tell the development server to proxy any unknown requests to your API server in development, add a `proxy` field to your `package.json`, for example: + +```js + "proxy": "http://localhost:4000", +``` + +This way, when you `fetch('/api/todos')` in development, the development server will recognize that it’s not a static asset, and will proxy your request to `http://localhost:4000/api/todos` as a fallback. The development server will **only** attempt to send requests without `text/html` in its `Accept` header to the proxy. + +Conveniently, this avoids [CORS issues](http://stackoverflow.com/questions/21854516/understanding-ajax-cors-and-security-considerations) and error messages like this in development: + +``` +Fetch API cannot load http://localhost:4000/api/todos. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. +``` + +Keep in mind that `proxy` only has effect in development (with `npm start`), and it is up to you to ensure that URLs like `/api/todos` point to the right thing in production. You don’t have to use the `/api` prefix. Any unrecognized request without a `text/html` accept header will be redirected to the specified `proxy`. + +The `proxy` option supports HTTP, HTTPS and WebSocket connections.
+If the `proxy` option is **not** flexible enough for you, alternatively you can: + +* [Configure the proxy yourself](#configuring-the-proxy-manually) +* Enable CORS on your server ([here’s how to do it for Express](http://enable-cors.org/server_expressjs.html)). +* Use [environment variables](#adding-custom-environment-variables) to inject the right server host and port into your app. + +### "Invalid Host Header" Errors After Configuring Proxy + +When you enable the `proxy` option, you opt into a more strict set of host checks. This is necessary because leaving the backend open to remote hosts makes your computer vulnerable to DNS rebinding attacks. The issue is explained in [this article](https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a) and [this issue](https://github.com/webpack/webpack-dev-server/issues/887). + +This shouldn’t affect you when developing on `localhost`, but if you develop remotely like [described here](https://github.com/facebookincubator/create-react-app/issues/2271), you will see this error in the browser after enabling the `proxy` option: + +>Invalid Host header + +To work around it, you can specify your public development host in a file called `.env.development` in the root of your project: + +``` +HOST=mypublicdevhost.com +``` + +If you restart the development server now and load the app from the specified host, it should work. + +If you are still having issues or if you’re using a more exotic environment like a cloud editor, you can bypass the host check completely by adding a line to `.env.development.local`. **Note that this is dangerous and exposes your machine to remote code execution from malicious websites:** + +``` +# NOTE: THIS IS DANGEROUS! +# It exposes your machine to attacks from the websites you visit. +DANGEROUSLY_DISABLE_HOST_CHECK=true +``` + +We don’t recommend this approach. + +### Configuring the Proxy Manually + +>Note: this feature is available with `react-scripts@1.0.0` and higher. + +If the `proxy` option is **not** flexible enough for you, you can specify an object in the following form (in `package.json`).
+You may also specify any configuration value [`http-proxy-middleware`](https://github.com/chimurai/http-proxy-middleware#options) or [`http-proxy`](https://github.com/nodejitsu/node-http-proxy#options) supports. +```js +{ + // ... + "proxy": { + "/api": { + "target": "", + "ws": true + // ... + } + } + // ... +} +``` + +All requests matching this path will be proxies, no exceptions. This includes requests for `text/html`, which the standard `proxy` option does not proxy. + +If you need to specify multiple proxies, you may do so by specifying additional entries. +Matches are regular expressions, so that you can use a regexp to match multiple paths. +```js +{ + // ... + "proxy": { + // Matches any request starting with /api + "/api": { + "target": "", + "ws": true + // ... + }, + // Matches any request starting with /foo + "/foo": { + "target": "", + "ssl": true, + "pathRewrite": { + "^/foo": "/foo/beta" + } + // ... + }, + // Matches /bar/abc.html but not /bar/sub/def.html + "/bar/[^/]*[.]html": { + "target": "", + // ... + }, + // Matches /baz/abc.html and /baz/sub/def.html + "/baz/.*/.*[.]html": { + "target": "" + // ... + } + } + // ... +} +``` + +### Configuring a WebSocket Proxy + +When setting up a WebSocket proxy, there are a some extra considerations to be aware of. + +If you’re using a WebSocket engine like [Socket.io](https://socket.io/), you must have a Socket.io server running that you can use as the proxy target. Socket.io will not work with a standard WebSocket server. Specifically, don't expect Socket.io to work with [the websocket.org echo test](http://websocket.org/echo.html). + +There’s some good documentation available for [setting up a Socket.io server](https://socket.io/docs/). + +Standard WebSockets **will** work with a standard WebSocket server as well as the websocket.org echo test. You can use libraries like [ws](https://github.com/websockets/ws) for the server, with [native WebSockets in the browser](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket). + +Either way, you can proxy WebSocket requests manually in `package.json`: + +```js +{ + // ... + "proxy": { + "/socket": { + // Your compatible WebSocket server + "target": "ws://", + // Tell http-proxy-middleware that this is a WebSocket proxy. + // Also allows you to proxy WebSocket requests without an additional HTTP request + // https://github.com/chimurai/http-proxy-middleware#external-websocket-upgrade + "ws": true + // ... + } + } + // ... +} +``` + +## Using HTTPS in Development + +>Note: this feature is available with `react-scripts@0.4.0` and higher. + +You may require the dev server to serve pages over HTTPS. One particular case where this could be useful is when using [the "proxy" feature](#proxying-api-requests-in-development) to proxy requests to an API server when that API server is itself serving HTTPS. + +To do this, set the `HTTPS` environment variable to `true`, then start the dev server as usual with `npm start`: + +#### Windows (cmd.exe) + +```cmd +set HTTPS=true&&npm start +``` + +(Note: the lack of whitespace is intentional.) + +#### Linux, macOS (Bash) + +```bash +HTTPS=true npm start +``` + +Note that the server will use a self-signed certificate, so your web browser will almost definitely display a warning upon accessing the page. + +## Generating Dynamic `` Tags on the Server + +Since Create React App doesn’t support server rendering, you might be wondering how to make `` tags dynamic and reflect the current URL. To solve this, we recommend to add placeholders into the HTML, like this: + +```html + + + + + +``` + +Then, on the server, regardless of the backend you use, you can read `index.html` into memory and replace `__OG_TITLE__`, `__OG_DESCRIPTION__`, and any other placeholders with values depending on the current URL. Just make sure to sanitize and escape the interpolated values so that they are safe to embed into HTML! + +If you use a Node server, you can even share the route matching logic between the client and the server. However duplicating it also works fine in simple cases. + +## Pre-Rendering into Static HTML Files + +If you’re hosting your `build` with a static hosting provider you can use [react-snapshot](https://www.npmjs.com/package/react-snapshot) or [react-snap](https://github.com/stereobooster/react-snap) to generate HTML pages for each route, or relative link, in your application. These pages will then seamlessly become active, or “hydrated”, when the JavaScript bundle has loaded. + +There are also opportunities to use this outside of static hosting, to take the pressure off the server when generating and caching routes. + +The primary benefit of pre-rendering is that you get the core content of each page _with_ the HTML payload—regardless of whether or not your JavaScript bundle successfully downloads. It also increases the likelihood that each route of your application will be picked up by search engines. + +You can read more about [zero-configuration pre-rendering (also called snapshotting) here](https://medium.com/superhighfives/an-almost-static-stack-6df0a2791319). + +## Injecting Data from the Server into the Page + +Similarly to the previous section, you can leave some placeholders in the HTML that inject global variables, for example: + +```js + + + + +``` + +Then, on the server, you can replace `__SERVER_DATA__` with a JSON of real data right before sending the response. The client code can then read `window.SERVER_DATA` to use it. **Make sure to [sanitize the JSON before sending it to the client](https://medium.com/node-security/the-most-common-xss-vulnerability-in-react-js-applications-2bdffbcc1fa0) as it makes your app vulnerable to XSS attacks.** + +## Running Tests + +>Note: this feature is available with `react-scripts@0.3.0` and higher.
+>[Read the migration guide to learn how to enable it in older projects!](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md#migrating-from-023-to-030) + +Create React App uses [Jest](https://facebook.github.io/jest/) as its test runner. To prepare for this integration, we did a [major revamp](https://facebook.github.io/jest/blog/2016/09/01/jest-15.html) of Jest so if you heard bad things about it years ago, give it another try. + +Jest is a Node-based runner. This means that the tests always run in a Node environment and not in a real browser. This lets us enable fast iteration speed and prevent flakiness. + +While Jest provides browser globals such as `window` thanks to [jsdom](https://github.com/tmpvar/jsdom), they are only approximations of the real browser behavior. Jest is intended to be used for unit tests of your logic and your components rather than the DOM quirks. + +We recommend that you use a separate tool for browser end-to-end tests if you need them. They are beyond the scope of Create React App. + +### Filename Conventions + +Jest will look for test files with any of the following popular naming conventions: + +* Files with `.js` suffix in `__tests__` folders. +* Files with `.test.js` suffix. +* Files with `.spec.js` suffix. + +The `.test.js` / `.spec.js` files (or the `__tests__` folders) can be located at any depth under the `src` top level folder. + +We recommend to put the test files (or `__tests__` folders) next to the code they are testing so that relative imports appear shorter. For example, if `App.test.js` and `App.js` are in the same folder, the test just needs to `import App from './App'` instead of a long relative path. Colocation also helps find tests more quickly in larger projects. + +### Command Line Interface + +When you run `npm test`, Jest will launch in the watch mode. Every time you save a file, it will re-run the tests, just like `npm start` recompiles the code. + +The watcher includes an interactive command-line interface with the ability to run all tests, or focus on a search pattern. It is designed this way so that you can keep it open and enjoy fast re-runs. You can learn the commands from the “Watch Usage” note that the watcher prints after every run: + +![Jest watch mode](http://facebook.github.io/jest/img/blog/15-watch.gif) + +### Version Control Integration + +By default, when you run `npm test`, Jest will only run the tests related to files changed since the last commit. This is an optimization designed to make your tests run fast regardless of how many tests you have. However it assumes that you don’t often commit the code that doesn’t pass the tests. + +Jest will always explicitly mention that it only ran tests related to the files changed since the last commit. You can also press `a` in the watch mode to force Jest to run all tests. + +Jest will always run all tests on a [continuous integration](#continuous-integration) server or if the project is not inside a Git or Mercurial repository. + +### Writing Tests + +To create tests, add `it()` (or `test()`) blocks with the name of the test and its code. You may optionally wrap them in `describe()` blocks for logical grouping but this is neither required nor recommended. + +Jest provides a built-in `expect()` global function for making assertions. A basic test could look like this: + +```js +import sum from './sum'; + +it('sums numbers', () => { + expect(sum(1, 2)).toEqual(3); + expect(sum(2, 2)).toEqual(4); +}); +``` + +All `expect()` matchers supported by Jest are [extensively documented here](https://facebook.github.io/jest/docs/en/expect.html#content).
+You can also use [`jest.fn()` and `expect(fn).toBeCalled()`](https://facebook.github.io/jest/docs/en/expect.html#tohavebeencalled) to create “spies” or mock functions. + +### Testing Components + +There is a broad spectrum of component testing techniques. They range from a “smoke test” verifying that a component renders without throwing, to shallow rendering and testing some of the output, to full rendering and testing component lifecycle and state changes. + +Different projects choose different testing tradeoffs based on how often components change, and how much logic they contain. If you haven’t decided on a testing strategy yet, we recommend that you start with creating simple smoke tests for your components: + +```js +import React from 'react'; +import ReactDOM from 'react-dom'; +import App from './App'; + +it('renders without crashing', () => { + const div = document.createElement('div'); + ReactDOM.render(, div); +}); +``` + +This test mounts a component and makes sure that it didn’t throw during rendering. Tests like this provide a lot value with very little effort so they are great as a starting point, and this is the test you will find in `src/App.test.js`. + +When you encounter bugs caused by changing components, you will gain a deeper insight into which parts of them are worth testing in your application. This might be a good time to introduce more specific tests asserting specific expected output or behavior. + +If you’d like to test components in isolation from the child components they render, we recommend using [`shallow()` rendering API](http://airbnb.io/enzyme/docs/api/shallow.html) from [Enzyme](http://airbnb.io/enzyme/). To install it, run: + +```sh +npm install --save enzyme enzyme-adapter-react-16 react-test-renderer +``` + +Alternatively you may use `yarn`: + +```sh +yarn add enzyme enzyme-adapter-react-16 react-test-renderer +``` + +As of Enzyme 3, you will need to install Enzyme along with an Adapter corresponding to the version of React you are using. (The examples above use the adapter for React 16.) + +The adapter will also need to be configured in your [global setup file](#initializing-test-environment): + +#### `src/setupTests.js` +```js +import { configure } from 'enzyme'; +import Adapter from 'enzyme-adapter-react-16'; + +configure({ adapter: new Adapter() }); +``` + +Now you can write a smoke test with it: + +```js +import React from 'react'; +import { shallow } from 'enzyme'; +import App from './App'; + +it('renders without crashing', () => { + shallow(); +}); +``` + +Unlike the previous smoke test using `ReactDOM.render()`, this test only renders `` and doesn’t go deeper. For example, even if `` itself renders a ` + )} + + ); +}; + +TodoListFooter.propTypes = { + completedCount: PropTypes.number.isRequired, + activeCount: PropTypes.number.isRequired, + onClearCompleted: PropTypes.func.isRequired +}; + +export default TodoListFooter; diff --git a/src/GraphQL.Relay.Todo/ClientApp/src/components/TodoTextInput.js b/src/GraphQL.Relay.Todo/ClientApp/src/components/TodoTextInput.js new file mode 100644 index 000000000..21455728d --- /dev/null +++ b/src/GraphQL.Relay.Todo/ClientApp/src/components/TodoTextInput.js @@ -0,0 +1,56 @@ +import React, { Component } from 'react' +import PropTypes from 'prop-types' +import classnames from 'classnames' + +export default class TodoTextInput extends Component { + static propTypes = { + onSave: PropTypes.func.isRequired, + text: PropTypes.string, + placeholder: PropTypes.string, + editing: PropTypes.bool, + newTodo: PropTypes.bool + } + + state = { + text: this.props.text || '' + } + + handleSubmit = e => { + const text = e.target.value.trim() + if (e.which === 13) { + this.props.onSave(text) + if (this.props.newTodo) { + this.setState({ text: '' }) + } + } + } + + handleChange = e => { + this.setState({ text: e.target.value }) + } + + handleBlur = e => { + if (!this.props.newTodo) { + this.props.onSave(e.target.value) + } + } + + render() { + return ( +
+ +
+ ) + } +} diff --git a/src/GraphQL.Relay.Todo/ClientApp/src/components/__generated__/TodoApp_viewer.graphql.js b/src/GraphQL.Relay.Todo/ClientApp/src/components/__generated__/TodoApp_viewer.graphql.js new file mode 100644 index 000000000..e370a2b22 --- /dev/null +++ b/src/GraphQL.Relay.Todo/ClientApp/src/components/__generated__/TodoApp_viewer.graphql.js @@ -0,0 +1,71 @@ +/** + * @flow + */ + +/* eslint-disable */ + +'use strict'; + +/*:: +<<<<<<< Updated upstream:src/GraphQL.Relay.Todo/ClientApp/components/__generated__/TodoApp_viewer.graphql.js +import type {ConcreteFragment} from 'relay-runtime'; +export type TodoApp_viewer = {| + +id: string; + +totalCount: ?number; +======= +import type { ReaderFragment } from 'relay-runtime'; +import type { FragmentReference } from "relay-runtime"; +declare export opaque type TodoApp_viewer$ref: FragmentReference; +declare export opaque type TodoApp_viewer$fragmentType: TodoApp_viewer$ref; +export type TodoApp_viewer = {| + +id: string, + +totalCount: ?number, + +$refType: TodoApp_viewer$ref, +>>>>>>> Stashed changes:src/GraphQL.Relay.Todo/ClientApp/src/components/__generated__/TodoApp_viewer.graphql.js +|}; +*/ + + +const fragment /*: ConcreteFragment*/ = { + "argumentDefinitions": [], + "kind": "Fragment", + "metadata": null, + "name": "TodoApp_viewer", + "selections": [ + { + "kind": "ScalarField", + "alias": null, + "args": null, + "name": "id", + "storageKey": null + }, + { + "kind": "ScalarField", + "alias": null, + "args": null, + "name": "totalCount", + "storageKey": null +<<<<<<< Updated upstream:src/GraphQL.Relay.Todo/ClientApp/components/__generated__/TodoApp_viewer.graphql.js + }, + { + "kind": "FragmentSpread", + "name": "TodoListFooter_viewer", + "args": null + }, + { + "kind": "FragmentSpread", + "name": "TodoList_viewer", + "args": null +======= +>>>>>>> Stashed changes:src/GraphQL.Relay.Todo/ClientApp/src/components/__generated__/TodoApp_viewer.graphql.js + } + ], + "type": "User" +}; +<<<<<<< Updated upstream:src/GraphQL.Relay.Todo/ClientApp/components/__generated__/TodoApp_viewer.graphql.js +======= +// prettier-ignore +(node/*: any*/).hash = '9a4e63b5dbc7ffde130bfc47a79868dd'; +>>>>>>> Stashed changes:src/GraphQL.Relay.Todo/ClientApp/src/components/__generated__/TodoApp_viewer.graphql.js + +module.exports = fragment; diff --git a/src/GraphQL.Relay.Todo/ClientApp/src/fetchQuery.js b/src/GraphQL.Relay.Todo/ClientApp/src/fetchQuery.js new file mode 100644 index 000000000..9a4a1b0e9 --- /dev/null +++ b/src/GraphQL.Relay.Todo/ClientApp/src/fetchQuery.js @@ -0,0 +1,18 @@ +async function fetchQuery(text, variables) { + // Fetch data from GitHub's GraphQL API: + const response = await fetch('http://localhost:5000/graphql', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + query: text, + variables, + }), + }); + + // Get the response as JSON + return await response.json(); +} + +export default fetchQuery; \ No newline at end of file diff --git a/src/GraphQL.Relay.Todo/ClientApp/src/index.js b/src/GraphQL.Relay.Todo/ClientApp/src/index.js new file mode 100644 index 000000000..7d127e6f2 --- /dev/null +++ b/src/GraphQL.Relay.Todo/ClientApp/src/index.js @@ -0,0 +1,19 @@ +import 'todomvc-common'; +import 'todomvc-app-css/index.css'; + +import React from 'react'; +import ReactDOM from 'react-dom'; +import { BrowserRouter } from 'react-router-dom'; +import registerServiceWorker from './registerServiceWorker'; +import AppRoot from './App'; + +const baseUrl = document.getElementsByTagName('base')[0].getAttribute('href'); +const rootElement = document.getElementById('root'); + +ReactDOM.render( + + + , rootElement); + +registerServiceWorker(); + diff --git a/src/GraphQL.Relay.Todo/ClientApp/src/mutations/AddTodoMutation.js b/src/GraphQL.Relay.Todo/ClientApp/src/mutations/AddTodoMutation.js new file mode 100644 index 000000000..e4cc17829 --- /dev/null +++ b/src/GraphQL.Relay.Todo/ClientApp/src/mutations/AddTodoMutation.js @@ -0,0 +1,25 @@ +import { + commitMutation, + graphql, +} from 'react-relay'; +import { ConnectionHandler } from 'relay-runtime'; + +const mutation = graphql` + mutation AddTodoMutation($input: AddTodoInput!) { + addTodo(input:$input) { + todoEdge { + __typename + cursor + node { + id + complete + text + } + } + viewer { + id + totalCount + } + } + } +`; \ No newline at end of file diff --git a/src/GraphQL.Relay.Todo/ClientApp/mutations/__generated__/AddTodoMutation.graphql.js b/src/GraphQL.Relay.Todo/ClientApp/src/mutations/__generated__/AddTodoMutation.graphql.js similarity index 88% rename from src/GraphQL.Relay.Todo/ClientApp/mutations/__generated__/AddTodoMutation.graphql.js rename to src/GraphQL.Relay.Todo/ClientApp/src/mutations/__generated__/AddTodoMutation.graphql.js index acc3cb7b4..4d5a22738 100644 --- a/src/GraphQL.Relay.Todo/ClientApp/mutations/__generated__/AddTodoMutation.graphql.js +++ b/src/GraphQL.Relay.Todo/ClientApp/src/mutations/__generated__/AddTodoMutation.graphql.js @@ -8,7 +8,14 @@ 'use strict'; /*:: +<<<<<<< Updated upstream:src/GraphQL.Relay.Todo/ClientApp/mutations/__generated__/AddTodoMutation.graphql.js import type {ConcreteBatch} from 'relay-runtime'; +======= +import type { ConcreteRequest } from 'relay-runtime'; +export type AddTodoInput = {| + text?: ?string +|}; +>>>>>>> Stashed changes:src/GraphQL.Relay.Todo/ClientApp/src/mutations/__generated__/AddTodoMutation.graphql.js export type AddTodoMutationVariables = {| input: { clientMutationId?: ?string; @@ -291,7 +298,30 @@ const batch /*: ConcreteBatch*/ = { ], "storageKey": null } +<<<<<<< Updated upstream:src/GraphQL.Relay.Todo/ClientApp/mutations/__generated__/AddTodoMutation.graphql.js ] +======= + ], + "storageKey": null + } +]; +return { + "fragment": { + "argumentDefinitions": (v0/*: any*/), + "kind": "Fragment", + "metadata": null, + "name": "AddTodoMutation", + "selections": (v2/*: any*/), + "type": "TodoMutation", + "abstractKey": null + }, + "kind": "Request", + "operation": { + "argumentDefinitions": (v0/*: any*/), + "kind": "Operation", + "name": "AddTodoMutation", + "selections": (v2/*: any*/) +>>>>>>> Stashed changes:src/GraphQL.Relay.Todo/ClientApp/src/mutations/__generated__/AddTodoMutation.graphql.js }, "text": "mutation AddTodoMutation(\n $input: AddTodoInput!\n) {\n addTodo(input: $input) {\n todoEdge {\n __typename\n cursor\n node {\n id\n complete\n text\n }\n }\n viewer {\n id\n totalCount\n }\n }\n}\n" }; diff --git a/src/GraphQL.Relay.Todo/ClientApp/src/registerServiceWorker.js b/src/GraphQL.Relay.Todo/ClientApp/src/registerServiceWorker.js new file mode 100644 index 000000000..10b0bafb3 --- /dev/null +++ b/src/GraphQL.Relay.Todo/ClientApp/src/registerServiceWorker.js @@ -0,0 +1,108 @@ +// In production, we register a service worker to serve assets from local cache. + +// This lets the app load faster on subsequent visits in production, and gives +// it offline capabilities. However, it also means that developers (and users) +// will only see deployed updates on the "N+1" visit to a page, since previously +// cached resources are updated in the background. + +// To learn more about the benefits of this model, read https://goo.gl/KwvDNy. +// This link also includes instructions on opting out of this behavior. + +const isLocalhost = Boolean( + window.location.hostname === 'localhost' || + // [::1] is the IPv6 localhost address. + window.location.hostname === '[::1]' || + // 127.0.0.1/8 is considered localhost for IPv4. + window.location.hostname.match( + /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ + ) +); + +export default function register () { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { + // The URL constructor is available in all browsers that support SW. + const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + if (publicUrl.origin !== window.location.origin) { + // Our service worker won't work if PUBLIC_URL is on a different origin + // from what our page is served on. This might happen if a CDN is used to + // serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374 + return; + } + + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + + if (isLocalhost) { + // This is running on localhost. Lets check if a service worker still exists or not. + checkValidServiceWorker(swUrl); + } else { + // Is not local host. Just register service worker + registerValidSW(swUrl); + } + }); + } +} + +function registerValidSW (swUrl) { + navigator.serviceWorker + .register(swUrl) + .then(registration => { + registration.onupdatefound = () => { + const installingWorker = registration.installing; + installingWorker.onstatechange = () => { + if (installingWorker.state === 'installed') { + if (navigator.serviceWorker.controller) { + // At this point, the old content will have been purged and + // the fresh content will have been added to the cache. + // It's the perfect time to display a "New content is + // available; please refresh." message in your web app. + console.log('New content is available; please refresh.'); + } else { + // At this point, everything has been precached. + // It's the perfect time to display a + // "Content is cached for offline use." message. + console.log('Content is cached for offline use.'); + } + } + }; + }; + }) + .catch(error => { + console.error('Error during service worker registration:', error); + }); +} + +function checkValidServiceWorker (swUrl) { + // Check if the service worker can be found. If it can't reload the page. + fetch(swUrl) + .then(response => { + // Ensure service worker exists, and that we really are getting a JS file. + if ( + response.status === 404 || + response.headers.get('content-type').indexOf('javascript') === -1 + ) { + // No service worker found. Probably a different app. Reload the page. + navigator.serviceWorker.ready.then(registration => { + registration.unregister().then(() => { + window.location.reload(); + }); + }); + } else { + // Service worker found. Proceed as normal. + registerValidSW(swUrl); + } + }) + .catch(() => { + console.log( + 'No internet connection found. App is running in offline mode.' + ); + }); +} + +export function unregister () { + if ('serviceWorker' in navigator) { + navigator.serviceWorker.ready.then(registration => { + registration.unregister(); + }); + } +} diff --git a/src/GraphQL.Relay.Todo/ClientApp/src/setupProxy.js b/src/GraphQL.Relay.Todo/ClientApp/src/setupProxy.js new file mode 100644 index 000000000..06e9ad35d --- /dev/null +++ b/src/GraphQL.Relay.Todo/ClientApp/src/setupProxy.js @@ -0,0 +1,14 @@ +const createProxyMiddleware = require('http-proxy-middleware'); + +const context = [ + "/weatherforecast", +]; + +module.exports = function(app) { + const appProxy = createProxyMiddleware(context, { + target: 'http://localhost:5000', + secure: false + }); + + app.use(appProxy); +}; diff --git a/src/GraphQL.Relay.Todo/ClientApp/src/stores/todo.js b/src/GraphQL.Relay.Todo/ClientApp/src/stores/todo.js new file mode 100644 index 000000000..bd91276ab --- /dev/null +++ b/src/GraphQL.Relay.Todo/ClientApp/src/stores/todo.js @@ -0,0 +1,106 @@ +import { Store } from "laco"; + +export const TodoStore = new Store( + { + todos: [ + { + text: "Use Laco", + completed: false, + id: 0 + } + ], + visibilityFilter: "All" + }, + "TodoStore" +); + +export const addTodo = text => + TodoStore.set( + ({ todos }) => ({ + todos: [ + ...todos, + { + id: todos.reduce((maxId, todo) => Math.max(todo.id, maxId), -1) + 1, + completed: false, + text + } + ] + }), + "Add todo" + ); + +export const deleteTodo = id => + TodoStore.set( + ({ todos }) => ({ + todos: todos.filter(item => item.id !== id) + }), + "Delete todo" + ); + +export const editTodo = (id, text) => + TodoStore.set( + ({ todos }) => ({ + todos: todos.map(todo => (todo.id === id ? { ...todo, text } : todo)) + }), + "Edit todo" + ); + +export const completeTodo = id => + TodoStore.set( + ({ todos }) => ({ + todos: todos.map(todo => + todo.id === id ? { ...todo, completed: !todo.completed } : todo + ) + }), + "Complete todo" + ); + +export const completeAllTodos = () => { + const todos = TodoStore.get().todos; + const areAllMarked = todos.every(todo => todo.completed); + TodoStore.set( + () => ({ + todos: todos.map(todo => ({ + ...todo, + completed: !areAllMarked + })) + }), + "Complete all todos" + ); +}; + +export const clearCompletedTodos = () => + TodoStore.set( + ({ todos }) => ({ + todos: todos.filter(t => t.completed === false) + }), + "Clear completed todos" + ); + +export const getTodosCount = () => TodoStore.get().todos.length; + +export const getCompletedCount = todos => + todos.reduce((count, todo) => (todo.completed ? count + 1 : count), 0); + +// Visibility filter stuff +export const setVisibilityFilter = type => + TodoStore.set( + () => ({ + visibilityFilter: type + }), + "Set visibility" + ); + +export const getFilteredTodos = visibilityFilter => { + const todos = TodoStore.get().todos; + switch (visibilityFilter) { + case "All": + return todos; + case "Completed": + return todos.filter(t => t.completed); + case "Active": + return todos.filter(t => !t.completed); + default: + throw new Error("Unknown filter: " + visibilityFilter); + } +}; diff --git a/src/GraphQL.Relay.Todo/Controllers/WeatherForecastController.cs b/src/GraphQL.Relay.Todo/Controllers/WeatherForecastController.cs new file mode 100644 index 000000000..f489cf4e5 --- /dev/null +++ b/src/GraphQL.Relay.Todo/Controllers/WeatherForecastController.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; + +namespace GraphQL.Relay.Todo.Controllers +{ + [ApiController] + [Route("[controller]")] + public class WeatherForecastController : ControllerBase + { + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [HttpGet] + public IEnumerable Get() + { + return Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = DateTime.Now.AddDays(index), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } + } +} diff --git a/src/GraphQL.Relay.Todo/Database/TodoDatabase.cs b/src/GraphQL.Relay.Todo/Database/TodoDatabase.cs index 906d82500..00baa3197 100644 --- a/src/GraphQL.Relay.Todo/Database/TodoDatabase.cs +++ b/src/GraphQL.Relay.Todo/Database/TodoDatabase.cs @@ -1,7 +1,8 @@ -using System; +using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; namespace GraphQL.Relay.Todo { @@ -17,12 +18,24 @@ public class User { // public Lazy> Todos { get; set; } } +<<<<<<< Updated upstream public class Todos: ConcurrentDictionary { } public class Users: ConcurrentDictionary { public Users() : base() { this["me"] = new User { Id = "me"}; +======= + public class Todos : ConcurrentDictionary + { + + } + public class Users : ConcurrentDictionary + { + public Users() : base() + { + this["me"] = new User { Id = "me" }; +>>>>>>> Stashed changes } } diff --git a/src/GraphQL.Relay.Todo/GraphQL.Relay.Todo.csproj b/src/GraphQL.Relay.Todo/GraphQL.Relay.Todo.csproj index 3c1b9315c..c2df578d8 100644 --- a/src/GraphQL.Relay.Todo/GraphQL.Relay.Todo.csproj +++ b/src/GraphQL.Relay.Todo/GraphQL.Relay.Todo.csproj @@ -1,6 +1,7 @@ - + +<<<<<<< Updated upstream net5 $(NoWarn);1591;IDE1006 @@ -9,8 +10,59 @@ +======= + net6.0 + true + Latest + false + ClientApp\ + $(DefaultItemExcludes);$(SpaRoot)node_modules\** + http://localhost:5002 + npm start + + + + + + + + + + + + +>>>>>>> Stashed changes + + + + + + + + + + + + + + + + + + + + + + + wwwroot\%(RecursiveDir)%(FileName)%(Extension) + PreserveNewest + true + + + + diff --git a/src/GraphQL.Relay.Todo/Pages/Error.cshtml b/src/GraphQL.Relay.Todo/Pages/Error.cshtml new file mode 100644 index 000000000..6f92b9565 --- /dev/null +++ b/src/GraphQL.Relay.Todo/Pages/Error.cshtml @@ -0,0 +1,26 @@ +@page +@model ErrorModel +@{ + ViewData["Title"] = "Error"; +} + +

Error.

+

An error occurred while processing your request.

+ +@if (Model.ShowRequestId) +{ +

+ Request ID: @Model.RequestId +

+} + +

Development Mode

+

+ Swapping to the Development environment displays detailed information about the error that occurred. +

+

+ The Development environment shouldn't be enabled for deployed applications. + It can result in displaying sensitive information from exceptions to end users. + For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development + and restarting the app. +

diff --git a/src/GraphQL.Relay.Todo/Pages/Error.cshtml.cs b/src/GraphQL.Relay.Todo/Pages/Error.cshtml.cs new file mode 100644 index 000000000..e042a217b --- /dev/null +++ b/src/GraphQL.Relay.Todo/Pages/Error.cshtml.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.Extensions.Logging; + +namespace GraphQL.Relay.Todo.Pages +{ + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + public class ErrorModel : PageModel + { + private readonly ILogger _logger; + + public ErrorModel(ILogger logger) + { + _logger = logger; + } + + public string RequestId { get; set; } + + public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); + + public void OnGet() + { + RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; + } + } +} diff --git a/src/GraphQL.Relay.Todo/Pages/_ViewImports.cshtml b/src/GraphQL.Relay.Todo/Pages/_ViewImports.cshtml new file mode 100644 index 000000000..87ce26850 --- /dev/null +++ b/src/GraphQL.Relay.Todo/Pages/_ViewImports.cshtml @@ -0,0 +1,3 @@ +@using GraphQL.Relay.Todo +@namespace GraphQL.Relay.Todo.Pages +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/src/GraphQL.Relay.Todo/Program.cs b/src/GraphQL.Relay.Todo/Program.cs index 136ca850c..d06144c25 100644 --- a/src/GraphQL.Relay.Todo/Program.cs +++ b/src/GraphQL.Relay.Todo/Program.cs @@ -1,3 +1,4 @@ +<<<<<<< Updated upstream using System; using System.Collections.Generic; using System.IO; @@ -7,6 +8,15 @@ using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; +======= +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +>>>>>>> Stashed changes using Microsoft.Extensions.Logging; namespace GraphQL.Relay.Todo @@ -15,12 +25,14 @@ public class Program { public static void Main(string[] args) { - BuildWebHost(args).Run(); + CreateHostBuilder(args).Build().Run(); } - public static IWebHost BuildWebHost(string[] args) => - WebHost.CreateDefaultBuilder(args) - .UseStartup() - .Build(); + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }); } } diff --git a/src/GraphQL.Relay.Todo/Properties/launchSettings.json b/src/GraphQL.Relay.Todo/Properties/launchSettings.json index 57c709bcd..5791fb825 100644 --- a/src/GraphQL.Relay.Todo/Properties/launchSettings.json +++ b/src/GraphQL.Relay.Todo/Properties/launchSettings.json @@ -1,27 +1,35 @@ -{ +{ "iisSettings": { "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { +<<<<<<< Updated upstream "applicationUrl": "http://localhost:62774/", "sslPort": 44327 +======= + "applicationUrl": "http://localhost:15749", + "sslPort": 0 +>>>>>>> Stashed changes } }, "profiles": { - "IIS Express": { - "commandName": "IISExpress", + "GraphQL.Relay.Todo": { + "commandName": "Project", "launchBrowser": true, + "launchUrl": "http://localhost:5002", + "applicationUrl": "http://localhost:5000", "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy" } }, - "GraphQL.Relay.Todo": { - "commandName": "Project", + "IIS Express": { + "commandName": "IISExpress", "launchBrowser": true, "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "https://localhost:5001;http://localhost:5000" + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy" + } } } -} \ No newline at end of file +} diff --git a/src/GraphQL.Relay.Todo/README.md b/src/GraphQL.Relay.Todo/README.md deleted file mode 100644 index 23b65976d..000000000 --- a/src/GraphQL.Relay.Todo/README.md +++ /dev/null @@ -1,8 +0,0 @@ - - -## Getting started - -```sh -yarn install -dotnet run -``` diff --git a/src/GraphQL.Relay.Todo/Schema/Mutation.cs b/src/GraphQL.Relay.Todo/Schema/Mutation.cs index 8181c3360..e6230ac18 100644 --- a/src/GraphQL.Relay.Todo/Schema/Mutation.cs +++ b/src/GraphQL.Relay.Todo/Schema/Mutation.cs @@ -1,22 +1,61 @@ +<<<<<<< Updated upstream using System.Linq; using GraphQL.Relay.Types; using GraphQL.Types; using GraphQL.Types.Relay; using GraphQL.Types.Relay.DataObjects; +======= +using GraphQL.Relay.Types; +using GraphQL.Types; +using GraphQL.Types.Relay; +using GraphQL.Types.Relay.DataObjects; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +>>>>>>> Stashed changes namespace GraphQL.Relay.Todo.Schema { public class TodoMutation : MutationGraphType { - public TodoMutation() : base() + public TodoMutation() { +<<<<<<< Updated upstream Mutation("addTodo"); Mutation("changeTodoStatus"); Mutation("markAllTodos"); Mutation("removeCompletedTodos"); Mutation("removeTodo"); Mutation("renameTodo"); +======= + Field( + "addTodo", + arguments: new QueryArguments( + new QueryArgument> { Name = "input" } + ), + resolve: context => + { + var todo = Database.AddTodo(context.GetArgument("input").Text); + + return new + { + TodoEdge = new Edge + { + Node = todo, + Cursor = ConnectionUtils.CursorForObjectInConnection(Database.GetTodos(), todo) + }, + Viewer = Database.GetViewer(), + }; + }); + + //Mutation("changeTodoStatus"); + //Mutation("markAllTodos"); + //Mutation("removeCompletedTodos"); + //Mutation("removeTodo"); + //Mutation("renameTodo"); +>>>>>>> Stashed changes } } @@ -30,7 +69,7 @@ public AddTodoInput() } } - public class AddTodoPayload : MutationPayloadGraphType + public class AddTodoPayload : ObjectGraphType { public AddTodoPayload() @@ -39,6 +78,7 @@ public AddTodoPayload() Field>("todoEdge"); Field("viewer"); } +<<<<<<< Updated upstream public override object MutateAndGetPayload( MutationInputs inputs, @@ -247,4 +287,196 @@ IResolveFieldContext context }; } } +======= + } + + + //public class ChangeTodoStatusInput : MutationInputGraphType + //{ + // public ChangeTodoStatusInput() + // { + // Name = "ChangeTodoStatusInput"; + + // Field("id"); + // Field("complete"); + // } + //} + + //public class ChangeTodoStatusPayload : MutationPayloadGraphType + //{ + + // public ChangeTodoStatusPayload() + // { + // Name = "ChangeTodoStatusPayload"; + + // Field("todo"); + // Field("viewer"); + // } + + // public override object MutateAndGetPayload( + // MutationInputs inputs, + // IResolveFieldContext context + // ) + // { + // return new + // { + // Viewer = Database.GetViewer(), + // Todo = Database.ChangeTodoStatus( + // Node.FromGlobalId(inputs.Get("id")).Id, + // inputs.Get("complete") + // ), + // }; + // } + //} + + + //public class MarkAllTodosInput : MutationInputGraphType + //{ + // public MarkAllTodosInput() + // { + // Name = "MarkAllTodosInput"; + + // Field("complete"); + // } + //} + + //public class MarkAllTodosPayload : MutationPayloadGraphType + //{ + + // public MarkAllTodosPayload() + // { + // Name = "MarkAllTodosPayload"; + + // Field>("changedTodos"); + // Field("viewer"); + // } + + // public override object MutateAndGetPayload( + // MutationInputs inputs, + // IResolveFieldContext context + // ) + // { + // return new + // { + // Viewer = Database.GetViewer(), + // ChangedTodos = Database.MarkAllTodos( + // inputs.Get("complete") + // ), + // }; + // } + //} + + + //public class RemoveCompletedTodosInput : MutationInputGraphType + //{ + // public RemoveCompletedTodosInput() + // { + // Name = "RemoveCompletedTodosInput"; + // } + //} + + //public class RemoveCompletedTodosPayload : MutationPayloadGraphType + //{ + + // public RemoveCompletedTodosPayload() + // { + // Name = "RemoveCompletedTodosPayload"; + + // Field>("deletedTodoIds"); + // Field("viewer"); + // } + + // public override object MutateAndGetPayload( + // MutationInputs inputs, + // IResolveFieldContext context + // ) + // { + // return new + // { + // Viewer = Database.GetViewer(), + // DeletedTodoIds = Database + // .RemoveCompletedTodos(inputs.Get("complete")) + // .Select(id => Node.ToGlobalId("Todo", id)), + // }; + // } + //} + + + //public class RemoveTodoInput : MutationInputGraphType + //{ + // public RemoveTodoInput() + // { + // Name = "RemoveTodoInput"; + + // Field("id"); + // } + //} + + //public class RemoveTodoPayload : MutationPayloadGraphType + //{ + + // public RemoveTodoPayload() + // { + // Name = "RemoveTodoPayload"; + + // Field("deletedTodoId"); + // Field("viewer"); + // } + + // public override object MutateAndGetPayload( + // MutationInputs inputs, + // IResolveFieldContext context + // ) + // { + // Database.RemoveTodo( + // Node.FromGlobalId(inputs.Get("id")).Id + // ); + + // return new + // { + // Viewer = Database.GetViewer(), + // deletedTodoId = inputs.Get("id"), + // }; + // } + //} + + + //public class RenameTodoInput : MutationInputGraphType + //{ + // public RenameTodoInput() + // { + // Name = "RenameTodoInput"; + + // Field("id"); + // Field("text"); + // } + //} + + //public class RenameTodoPayload : MutationPayloadGraphType + //{ + + // public RenameTodoPayload() + // { + // Name = "RenameTodoPayload"; + + // Field("todo"); + // Field("viewer"); + // } + + // public override object MutateAndGetPayload( + // MutationInputs inputs, + // IResolveFieldContext context + // ) + // { + // return new + // { + // Viewer = Database.GetViewer(), + // Todo = Database.RenameTodo( + // Node.FromGlobalId(inputs.Get("id")).Id, + // inputs.Get("text") + // ), + // }; + // } + //} +>>>>>>> Stashed changes } diff --git a/src/GraphQL.Relay.Todo/Schema/Query.cs b/src/GraphQL.Relay.Todo/Schema/Query.cs index a23ff1698..00e9e3fdc 100644 --- a/src/GraphQL.Relay.Todo/Schema/Query.cs +++ b/src/GraphQL.Relay.Todo/Schema/Query.cs @@ -1,7 +1,14 @@ +<<<<<<< Updated upstream using GraphQL.Relay.Types; using GraphQL.Relay.Todo; +======= +using GraphQL.Relay.Types; +>>>>>>> Stashed changes using GraphQL.Types; +using System; +using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; namespace GraphQL.Relay.Todo.Schema { @@ -64,6 +71,9 @@ public UserGraphType() { public override User GetById(IResolveFieldContext context, string id) => Database.GetUserById(id); } +<<<<<<< Updated upstream +======= +>>>>>>> Stashed changes } diff --git a/src/GraphQL.Relay.Todo/Schema/Schema.cs b/src/GraphQL.Relay.Todo/Schema/TodoSchema.cs similarity index 52% rename from src/GraphQL.Relay.Todo/Schema/Schema.cs rename to src/GraphQL.Relay.Todo/Schema/TodoSchema.cs index 982d4fcab..3b6115052 100644 --- a/src/GraphQL.Relay.Todo/Schema/Schema.cs +++ b/src/GraphQL.Relay.Todo/Schema/TodoSchema.cs @@ -1,5 +1,12 @@ +<<<<<<< Updated upstream:src/GraphQL.Relay.Todo/Schema/Schema.cs using System; using GraphQL.Types; +======= +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +>>>>>>> Stashed changes:src/GraphQL.Relay.Todo/Schema/TodoSchema.cs namespace GraphQL.Relay.Todo.Schema { diff --git a/src/GraphQL.Relay.Todo/SchemaWriter.cs b/src/GraphQL.Relay.Todo/SchemaWriter.cs index 5deb1dd16..5446bca25 100644 --- a/src/GraphQL.Relay.Todo/SchemaWriter.cs +++ b/src/GraphQL.Relay.Todo/SchemaWriter.cs @@ -1,4 +1,10 @@ +<<<<<<< Updated upstream using System; +======= +using GraphQL.SystemTextJson; +using System; +using System.Collections.Generic; +>>>>>>> Stashed changes using System.Linq; using System.Threading.Tasks; using GraphQL.SystemTextJson; diff --git a/src/GraphQL.Relay.Todo/Startup.cs b/src/GraphQL.Relay.Todo/Startup.cs index 952ed7602..1c898af63 100644 --- a/src/GraphQL.Relay.Todo/Startup.cs +++ b/src/GraphQL.Relay.Todo/Startup.cs @@ -1,3 +1,4 @@ +<<<<<<< Updated upstream using System; using System.Collections.Generic; using System.IO; @@ -5,10 +6,15 @@ using System.Text; using System.Threading.Tasks; using GraphQL.Conversion; +======= +using GraphQL.Relay.Todo.Schema; +using GraphQL.Server; +>>>>>>> Stashed changes using GraphQL.SystemTextJson; using GraphQL.Relay.Todo.Schema; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +<<<<<<< Updated upstream using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.Hosting; @@ -16,14 +22,37 @@ using Microsoft.Extensions.Configuration; using GraphQL.Types; using GraphQL.Server; +======= +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using System.IO; +using System.Text; +using System.Threading.Tasks; +>>>>>>> Stashed changes namespace GraphQL.Relay.Todo { public class Startup { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddRouting(); + services.AddCors(opt => opt.AddPolicy("AllowAll", policy => + { + policy.AllowAnyOrigin() + .AllowAnyMethod() + .AllowAnyHeader(); + })); + + services.AddControllersWithViews(); services.AddScoped(); services.AddScoped(); services.AddGraphQL() @@ -31,8 +60,11 @@ public void ConfigureServices(IServiceCollection services) services.AddSingleton(); } + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public async void Configure(IApplicationBuilder app, IWebHostEnvironment env) { + app.UseCors("AllowAll"); + var writer = new SchemaWriter(new TodoSchema()); string schema = await writer.Generate(); @@ -46,12 +78,27 @@ public async void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseDeveloperExceptionPage(); } + else + { + app.UseExceptionHandler("/Error"); + } app - .UseStaticFiles() - .UseDefaultFiles() - .UseGraphQL() - .UseGraphQLGraphiQL(); + .UseStaticFiles() + .UseDefaultFiles() + .UseGraphQL() + .UseGraphQLGraphiQL(); + + app.UseRouting(); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllerRoute( + name: "default", + pattern: "{controller}/{action=Index}/{id?}"); + + endpoints.MapFallbackToFile("index.html"); + }); } } } diff --git a/src/GraphQL.Relay.Todo/WeatherForecast.cs b/src/GraphQL.Relay.Todo/WeatherForecast.cs new file mode 100644 index 000000000..0be045dd5 --- /dev/null +++ b/src/GraphQL.Relay.Todo/WeatherForecast.cs @@ -0,0 +1,15 @@ +using System; + +namespace GraphQL.Relay.Todo +{ + public class WeatherForecast + { + public DateTime Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string Summary { get; set; } + } +} diff --git a/src/GraphQL.Relay.Todo/appsettings.Development.json b/src/GraphQL.Relay.Todo/appsettings.Development.json new file mode 100644 index 000000000..84308c97f --- /dev/null +++ b/src/GraphQL.Relay.Todo/appsettings.Development.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.AspNetCore.SpaProxy": "Information", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/src/GraphQL.Relay.Todo/appsettings.json b/src/GraphQL.Relay.Todo/appsettings.json new file mode 100644 index 000000000..ad75fee41 --- /dev/null +++ b/src/GraphQL.Relay.Todo/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, +"AllowedHosts": "*" +} diff --git a/src/GraphQL.Relay.Todo/wwwroot/index.html b/src/GraphQL.Relay.Todo/wwwroot/index.html index 970c03c71..d969d42ff 100644 --- a/src/GraphQL.Relay.Todo/wwwroot/index.html +++ b/src/GraphQL.Relay.Todo/wwwroot/index.html @@ -5,6 +5,12 @@
+<<<<<<< Updated upstream +======= + + + +>>>>>>> Stashed changes diff --git a/src/GraphQL.Relay.Todo/wwwroot/schema.json b/src/GraphQL.Relay.Todo/wwwroot/schema.json index a6e7d9464..6f3458d4f 100644 --- a/src/GraphQL.Relay.Todo/wwwroot/schema.json +++ b/src/GraphQL.Relay.Todo/wwwroot/schema.json @@ -1 +1,5 @@ -{"data":{"__schema":{"queryType":{"name":"Query"},"mutationType":{"name":"Mutation"},"subscriptionType":null,"types":[{"kind":"ENUM","name":"__DirectiveLocation","description":"A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.","fields":null,"inputFields":null,"interfaces":null,"enumValues":[{"name":"QUERY","description":"Location adjacent to a query operation.","isDeprecated":false,"deprecationReason":null},{"name":"MUTATION","description":"Location adjacent to a mutation operation.","isDeprecated":false,"deprecationReason":null},{"name":"SUBSCRIPTION","description":"Location adjacent to a subscription operation.","isDeprecated":false,"deprecationReason":null},{"name":"FIELD","description":"Location adjacent to a field.","isDeprecated":false,"deprecationReason":null},{"name":"FRAGMENT_DEFINITION","description":"Location adjacent to a fragment definition.","isDeprecated":false,"deprecationReason":null},{"name":"FRAGMENT_SPREAD","description":"Location adjacent to a fragment spread.","isDeprecated":false,"deprecationReason":null},{"name":"INLINE_FRAGMENT","description":"Location adjacent to an inline fragment.","isDeprecated":false,"deprecationReason":null},{"name":"SCHEMA","description":"Location adjacent to a schema definition.","isDeprecated":false,"deprecationReason":null},{"name":"SCALAR","description":"Location adjacent to a scalar definition.","isDeprecated":false,"deprecationReason":null},{"name":"OBJECT","description":"Location adjacent to an object type definition.","isDeprecated":false,"deprecationReason":null},{"name":"FIELD_DEFINITION","description":"Location adjacent to a field definition.","isDeprecated":false,"deprecationReason":null},{"name":"ARGUMENT_DEFINITION","description":"Location adjacent to an argument definition.","isDeprecated":false,"deprecationReason":null},{"name":"INTERFACE","description":"Location adjacent to an interface definition.","isDeprecated":false,"deprecationReason":null},{"name":"UNION","description":"Location adjacent to a union definition.","isDeprecated":false,"deprecationReason":null},{"name":"ENUM","description":"Location adjacent to an enum definition","isDeprecated":false,"deprecationReason":null},{"name":"ENUM_VALUE","description":"Location adjacent to an enum value definition","isDeprecated":false,"deprecationReason":null},{"name":"INPUT_OBJECT","description":"Location adjacent to an input object type definition.","isDeprecated":false,"deprecationReason":null},{"name":"INPUT_FIELD_DEFINITION","description":"Location adjacent to an input object field definition.","isDeprecated":false,"deprecationReason":null}],"possibleTypes":null},{"kind":"ENUM","name":"__TypeKind","description":"An enum describing what kind of type a given __Type is.","fields":null,"inputFields":null,"interfaces":null,"enumValues":[{"name":"SCALAR","description":"Indicates this type is a scalar.","isDeprecated":false,"deprecationReason":null},{"name":"OBJECT","description":"Indicates this type is an object. \u0060fields\u0060 and \u0060possibleTypes\u0060 are valid fields.","isDeprecated":false,"deprecationReason":null},{"name":"INTERFACE","description":"Indicates this type is an interface. \u0060fields\u0060 and \u0060possibleTypes\u0060 are valid fields.","isDeprecated":false,"deprecationReason":null},{"name":"UNION","description":"Indicates this type is a union. \u0060possibleTypes\u0060 is a valid field.","isDeprecated":false,"deprecationReason":null},{"name":"ENUM","description":"Indicates this type is an enum. \u0060enumValues\u0060 is a valid field.","isDeprecated":false,"deprecationReason":null},{"name":"INPUT_OBJECT","description":"Indicates this type is an input object. \u0060inputFields\u0060 is a valid field.","isDeprecated":false,"deprecationReason":null},{"name":"LIST","description":"Indicates this type is a list. \u0060ofType\u0060 is a valid field.","isDeprecated":false,"deprecationReason":null},{"name":"NON_NULL","description":"Indicates this type is a non-null. \u0060ofType\u0060 is a valid field.","isDeprecated":false,"deprecationReason":null}],"possibleTypes":null},{"kind":"OBJECT","name":"__EnumValue","description":"One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.","fields":[{"name":"name","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"isDeprecated","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"deprecationReason","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"SCALAR","name":"String","description":null,"fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"SCALAR","name":"Boolean","description":null,"fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__Directive","description":"A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL\u0027s execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.","fields":[{"name":"name","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"locations","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"ENUM","name":"__DirectiveLocation","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"args","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__InputValue","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"onOperation","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":true,"deprecationReason":"Use \u0027locations\u0027."},{"name":"onFragment","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":true,"deprecationReason":"Use \u0027locations\u0027."},{"name":"onField","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":true,"deprecationReason":"Use \u0027locations\u0027."}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__InputValue","description":"Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.","fields":[{"name":"name","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"type","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"defaultValue","description":"A GraphQL-formatted string representing the default value for this input value.","args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__Type","description":"The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the \u0060__TypeKind\u0060 enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name and description, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.","fields":[{"name":"kind","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"ENUM","name":"__TypeKind","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"name","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"fields","description":null,"args":[{"name":"includeDeprecated","description":null,"type":{"kind":"SCALAR","name":"Boolean","ofType":null},"defaultValue":"false"}],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Field","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"interfaces","description":null,"args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"possibleTypes","description":null,"args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"enumValues","description":null,"args":[{"name":"includeDeprecated","description":null,"type":{"kind":"SCALAR","name":"Boolean","ofType":null},"defaultValue":"false"}],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__EnumValue","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"inputFields","description":null,"args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__InputValue","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"ofType","description":null,"args":[],"type":{"kind":"OBJECT","name":"__Type","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__Field","description":"Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.","fields":[{"name":"name","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"args","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__InputValue","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"type","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"isDeprecated","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"deprecationReason","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__Schema","description":"A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.","fields":[{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"types","description":"A list of all types supported by this server.","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"queryType","description":"The type that query operations will be rooted at.","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"mutationType","description":"If this server supports mutation, the type that mutation operations will be rooted at.","args":[],"type":{"kind":"OBJECT","name":"__Type","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"subscriptionType","description":"If this server supports subscription, the type that subscription operations will be rooted at.","args":[],"type":{"kind":"OBJECT","name":"__Type","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"directives","description":"A list of all directives supported by this server.","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Directive","ofType":null}}}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"Query","description":null,"fields":[{"name":"node","description":"Fetches an object given its global Id","args":[{"name":"id","description":"The global Id of the object","type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"ID","ofType":null}},"defaultValue":null}],"type":{"kind":"INTERFACE","name":"Node","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"viewer","description":null,"args":[],"type":{"kind":"OBJECT","name":"User","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"INTERFACE","name":"Node","description":null,"fields":[{"name":"id","description":"Global node Id","args":[],"type":{"kind":"SCALAR","name":"ID","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":[{"kind":"OBJECT","name":"Todo","ofType":null},{"kind":"OBJECT","name":"User","ofType":null}]},{"kind":"SCALAR","name":"ID","description":null,"fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"User","description":null,"fields":[{"name":"userId","description":"The Id of the User","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"id","description":"The Global Id of the User","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"ID","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"todos","description":null,"args":[{"name":"after","description":"Only look at connected edges with cursors greater than the value of \u0060after\u0060.","type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null},{"name":"first","description":"Specifies the number of edges to return starting from \u0060after\u0060 or the first entry if \u0060after\u0060 is not specified.","type":{"kind":"SCALAR","name":"Int","ofType":null},"defaultValue":null},{"name":"status","description":"Filter todos by their status","type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":"\u0022any\u0022"}],"type":{"kind":"OBJECT","name":"TodoConnection","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"totalCount","description":null,"args":[],"type":{"kind":"SCALAR","name":"Int","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"completedCount","description":null,"args":[],"type":{"kind":"SCALAR","name":"Int","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[{"kind":"INTERFACE","name":"Node","ofType":null}],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"TodoConnection","description":"A connection from an object to a list of objects of type \u0060Todo\u0060.","fields":[{"name":"totalCount","description":"A count of the total number of objects in this connection, ignoring pagination. This allows a client to fetch the first five objects by passing \u00225\u0022 as the argument to \u0060first\u0060, then fetch the total count so it could display \u00225 of 83\u0022, for example. In cases where we employ infinite scrolling or don\u0027t have an exact count of entries, this field will return \u0060null\u0060.","args":[],"type":{"kind":"SCALAR","name":"Int","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"pageInfo","description":"Information to aid in pagination.","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"PageInfo","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"edges","description":"A list of all of the edges returned in the connection.","args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"OBJECT","name":"TodoEdge","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"items","description":"A list of all of the objects returned in the connection. This is a convenience field provided for quickly exploring the API; rather than querying for \u0022{ edges { node } }\u0022 when no edge data is needed, this field can be used instead. Note that when clients like Relay need to fetch the \u0022cursor\u0022 field on the edge to enable efficient pagination, this shortcut cannot be used, and the full \u0022{ edges { node } } \u0022 version should be used instead.","args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"OBJECT","name":"Todo","ofType":null}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"SCALAR","name":"Int","description":null,"fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"PageInfo","description":"Information about pagination in a connection.","fields":[{"name":"hasNextPage","description":"When paginating forwards, are there more items?","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"hasPreviousPage","description":"When paginating backwards, are there more items?","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"startCursor","description":"When paginating backwards, the cursor to continue.","args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"endCursor","description":"When paginating forwards, the cursor to continue.","args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"TodoEdge","description":"An edge in a connection from an object to another object of type \u0060Todo\u0060.","fields":[{"name":"cursor","description":"A cursor for use in pagination","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"node","description":"The item at the end of the edge","args":[],"type":{"kind":"OBJECT","name":"Todo","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"Todo","description":null,"fields":[{"name":"todoId","description":"The Id of the Todo","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"id","description":"The Global Id of the Todo","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"ID","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"text","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"complete","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[{"kind":"INTERFACE","name":"Node","ofType":null}],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"Mutation","description":null,"fields":[{"name":"addTodo","description":null,"args":[{"name":"input","description":null,"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"INPUT_OBJECT","name":"AddTodoInput","ofType":null}},"defaultValue":null}],"type":{"kind":"OBJECT","name":"AddTodoPayload","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"changeTodoStatus","description":null,"args":[{"name":"input","description":null,"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"INPUT_OBJECT","name":"ChangeTodoStatusInput","ofType":null}},"defaultValue":null}],"type":{"kind":"OBJECT","name":"ChangeTodoStatusPayload","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"markAllTodos","description":null,"args":[{"name":"input","description":null,"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"INPUT_OBJECT","name":"MarkAllTodosInput","ofType":null}},"defaultValue":null}],"type":{"kind":"OBJECT","name":"MarkAllTodosPayload","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"removeCompletedTodos","description":null,"args":[{"name":"input","description":null,"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"INPUT_OBJECT","name":"RemoveCompletedTodosInput","ofType":null}},"defaultValue":null}],"type":{"kind":"OBJECT","name":"RemoveCompletedTodosPayload","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"removeTodo","description":null,"args":[{"name":"input","description":null,"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"INPUT_OBJECT","name":"RemoveTodoInput","ofType":null}},"defaultValue":null}],"type":{"kind":"OBJECT","name":"RemoveTodoPayload","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"renameTodo","description":null,"args":[{"name":"input","description":null,"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"INPUT_OBJECT","name":"RenameTodoInput","ofType":null}},"defaultValue":null}],"type":{"kind":"OBJECT","name":"RenameTodoPayload","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"AddTodoPayload","description":null,"fields":[{"name":"clientMutationId","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"todoEdge","description":null,"args":[],"type":{"kind":"OBJECT","name":"TodoEdge","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"viewer","description":null,"args":[],"type":{"kind":"OBJECT","name":"User","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"INPUT_OBJECT","name":"AddTodoInput","description":null,"fields":null,"inputFields":[{"name":"clientMutationId","description":null,"type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null},{"name":"text","description":null,"type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null}],"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"ChangeTodoStatusPayload","description":null,"fields":[{"name":"clientMutationId","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"todo","description":null,"args":[],"type":{"kind":"OBJECT","name":"Todo","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"viewer","description":null,"args":[],"type":{"kind":"OBJECT","name":"User","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"INPUT_OBJECT","name":"ChangeTodoStatusInput","description":null,"fields":null,"inputFields":[{"name":"clientMutationId","description":null,"type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null},{"name":"id","description":null,"type":{"kind":"SCALAR","name":"ID","ofType":null},"defaultValue":null},{"name":"complete","description":null,"type":{"kind":"SCALAR","name":"Boolean","ofType":null},"defaultValue":null}],"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"MarkAllTodosPayload","description":null,"fields":[{"name":"clientMutationId","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"changedTodos","description":null,"args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"OBJECT","name":"Todo","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"viewer","description":null,"args":[],"type":{"kind":"OBJECT","name":"User","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"INPUT_OBJECT","name":"MarkAllTodosInput","description":null,"fields":null,"inputFields":[{"name":"clientMutationId","description":null,"type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null},{"name":"complete","description":null,"type":{"kind":"SCALAR","name":"Boolean","ofType":null},"defaultValue":null}],"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"RemoveCompletedTodosPayload","description":null,"fields":[{"name":"clientMutationId","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"deletedTodoIds","description":null,"args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"SCALAR","name":"ID","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"viewer","description":null,"args":[],"type":{"kind":"OBJECT","name":"User","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"INPUT_OBJECT","name":"RemoveCompletedTodosInput","description":null,"fields":null,"inputFields":[{"name":"clientMutationId","description":null,"type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null}],"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"RemoveTodoPayload","description":null,"fields":[{"name":"clientMutationId","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"deletedTodoId","description":null,"args":[],"type":{"kind":"SCALAR","name":"ID","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"viewer","description":null,"args":[],"type":{"kind":"OBJECT","name":"User","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"INPUT_OBJECT","name":"RemoveTodoInput","description":null,"fields":null,"inputFields":[{"name":"clientMutationId","description":null,"type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null},{"name":"id","description":null,"type":{"kind":"SCALAR","name":"ID","ofType":null},"defaultValue":null}],"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"RenameTodoPayload","description":null,"fields":[{"name":"clientMutationId","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"todo","description":null,"args":[],"type":{"kind":"OBJECT","name":"Todo","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"viewer","description":null,"args":[],"type":{"kind":"OBJECT","name":"User","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"INPUT_OBJECT","name":"RenameTodoInput","description":null,"fields":null,"inputFields":[{"name":"clientMutationId","description":null,"type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null},{"name":"id","description":null,"type":{"kind":"SCALAR","name":"ID","ofType":null},"defaultValue":null},{"name":"text","description":null,"type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null}],"interfaces":null,"enumValues":null,"possibleTypes":null}],"directives":[{"name":"include","description":"Directs the executor to include this field or fragment only when the \u0027if\u0027 argument is true.","locations":["FIELD","FRAGMENT_SPREAD","INLINE_FRAGMENT"],"args":[{"name":"if","description":"Included when true.","type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"defaultValue":null}]},{"name":"skip","description":"Directs the executor to skip this field or fragment when the \u0027if\u0027 argument is true.","locations":["FIELD","FRAGMENT_SPREAD","INLINE_FRAGMENT"],"args":[{"name":"if","description":"Skipped when true.","type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"defaultValue":null}]},{"name":"deprecated","description":"Marks an element of a GraphQL schema as no longer supported.","locations":["FIELD_DEFINITION","ENUM_VALUE"],"args":[{"name":"reason","description":"Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted in [Markdown](https://daringfireball.net/projects/markdown/).","type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":"\u0022No longer supported\u0022"}]}]}}} \ No newline at end of file +<<<<<<< Updated upstream +{"data":{"__schema":{"queryType":{"name":"Query"},"mutationType":{"name":"Mutation"},"subscriptionType":null,"types":[{"kind":"ENUM","name":"__DirectiveLocation","description":"A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.","fields":null,"inputFields":null,"interfaces":null,"enumValues":[{"name":"QUERY","description":"Location adjacent to a query operation.","isDeprecated":false,"deprecationReason":null},{"name":"MUTATION","description":"Location adjacent to a mutation operation.","isDeprecated":false,"deprecationReason":null},{"name":"SUBSCRIPTION","description":"Location adjacent to a subscription operation.","isDeprecated":false,"deprecationReason":null},{"name":"FIELD","description":"Location adjacent to a field.","isDeprecated":false,"deprecationReason":null},{"name":"FRAGMENT_DEFINITION","description":"Location adjacent to a fragment definition.","isDeprecated":false,"deprecationReason":null},{"name":"FRAGMENT_SPREAD","description":"Location adjacent to a fragment spread.","isDeprecated":false,"deprecationReason":null},{"name":"INLINE_FRAGMENT","description":"Location adjacent to an inline fragment.","isDeprecated":false,"deprecationReason":null},{"name":"SCHEMA","description":"Location adjacent to a schema definition.","isDeprecated":false,"deprecationReason":null},{"name":"SCALAR","description":"Location adjacent to a scalar definition.","isDeprecated":false,"deprecationReason":null},{"name":"OBJECT","description":"Location adjacent to an object type definition.","isDeprecated":false,"deprecationReason":null},{"name":"FIELD_DEFINITION","description":"Location adjacent to a field definition.","isDeprecated":false,"deprecationReason":null},{"name":"ARGUMENT_DEFINITION","description":"Location adjacent to an argument definition.","isDeprecated":false,"deprecationReason":null},{"name":"INTERFACE","description":"Location adjacent to an interface definition.","isDeprecated":false,"deprecationReason":null},{"name":"UNION","description":"Location adjacent to a union definition.","isDeprecated":false,"deprecationReason":null},{"name":"ENUM","description":"Location adjacent to an enum definition","isDeprecated":false,"deprecationReason":null},{"name":"ENUM_VALUE","description":"Location adjacent to an enum value definition","isDeprecated":false,"deprecationReason":null},{"name":"INPUT_OBJECT","description":"Location adjacent to an input object type definition.","isDeprecated":false,"deprecationReason":null},{"name":"INPUT_FIELD_DEFINITION","description":"Location adjacent to an input object field definition.","isDeprecated":false,"deprecationReason":null}],"possibleTypes":null},{"kind":"ENUM","name":"__TypeKind","description":"An enum describing what kind of type a given __Type is.","fields":null,"inputFields":null,"interfaces":null,"enumValues":[{"name":"SCALAR","description":"Indicates this type is a scalar.","isDeprecated":false,"deprecationReason":null},{"name":"OBJECT","description":"Indicates this type is an object. \u0060fields\u0060 and \u0060possibleTypes\u0060 are valid fields.","isDeprecated":false,"deprecationReason":null},{"name":"INTERFACE","description":"Indicates this type is an interface. \u0060fields\u0060 and \u0060possibleTypes\u0060 are valid fields.","isDeprecated":false,"deprecationReason":null},{"name":"UNION","description":"Indicates this type is a union. \u0060possibleTypes\u0060 is a valid field.","isDeprecated":false,"deprecationReason":null},{"name":"ENUM","description":"Indicates this type is an enum. \u0060enumValues\u0060 is a valid field.","isDeprecated":false,"deprecationReason":null},{"name":"INPUT_OBJECT","description":"Indicates this type is an input object. \u0060inputFields\u0060 is a valid field.","isDeprecated":false,"deprecationReason":null},{"name":"LIST","description":"Indicates this type is a list. \u0060ofType\u0060 is a valid field.","isDeprecated":false,"deprecationReason":null},{"name":"NON_NULL","description":"Indicates this type is a non-null. \u0060ofType\u0060 is a valid field.","isDeprecated":false,"deprecationReason":null}],"possibleTypes":null},{"kind":"OBJECT","name":"__EnumValue","description":"One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.","fields":[{"name":"name","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"isDeprecated","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"deprecationReason","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"SCALAR","name":"String","description":null,"fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"SCALAR","name":"Boolean","description":null,"fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__Directive","description":"A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL\u0027s execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.","fields":[{"name":"name","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"locations","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"ENUM","name":"__DirectiveLocation","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"args","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__InputValue","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"onOperation","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":true,"deprecationReason":"Use \u0027locations\u0027."},{"name":"onFragment","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":true,"deprecationReason":"Use \u0027locations\u0027."},{"name":"onField","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":true,"deprecationReason":"Use \u0027locations\u0027."}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__InputValue","description":"Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.","fields":[{"name":"name","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"type","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"defaultValue","description":"A GraphQL-formatted string representing the default value for this input value.","args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__Type","description":"The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the \u0060__TypeKind\u0060 enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name and description, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.","fields":[{"name":"kind","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"ENUM","name":"__TypeKind","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"name","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"fields","description":null,"args":[{"name":"includeDeprecated","description":null,"type":{"kind":"SCALAR","name":"Boolean","ofType":null},"defaultValue":"false"}],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Field","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"interfaces","description":null,"args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"possibleTypes","description":null,"args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"enumValues","description":null,"args":[{"name":"includeDeprecated","description":null,"type":{"kind":"SCALAR","name":"Boolean","ofType":null},"defaultValue":"false"}],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__EnumValue","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"inputFields","description":null,"args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__InputValue","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"ofType","description":null,"args":[],"type":{"kind":"OBJECT","name":"__Type","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__Field","description":"Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.","fields":[{"name":"name","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"args","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__InputValue","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"type","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"isDeprecated","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"deprecationReason","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__Schema","description":"A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.","fields":[{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"types","description":"A list of all types supported by this server.","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"queryType","description":"The type that query operations will be rooted at.","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"mutationType","description":"If this server supports mutation, the type that mutation operations will be rooted at.","args":[],"type":{"kind":"OBJECT","name":"__Type","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"subscriptionType","description":"If this server supports subscription, the type that subscription operations will be rooted at.","args":[],"type":{"kind":"OBJECT","name":"__Type","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"directives","description":"A list of all directives supported by this server.","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Directive","ofType":null}}}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"Query","description":null,"fields":[{"name":"node","description":"Fetches an object given its global Id","args":[{"name":"id","description":"The global Id of the object","type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"ID","ofType":null}},"defaultValue":null}],"type":{"kind":"INTERFACE","name":"Node","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"viewer","description":null,"args":[],"type":{"kind":"OBJECT","name":"User","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"INTERFACE","name":"Node","description":null,"fields":[{"name":"id","description":"Global node Id","args":[],"type":{"kind":"SCALAR","name":"ID","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":[{"kind":"OBJECT","name":"Todo","ofType":null},{"kind":"OBJECT","name":"User","ofType":null}]},{"kind":"SCALAR","name":"ID","description":null,"fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"User","description":null,"fields":[{"name":"userId","description":"The Id of the User","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"id","description":"The Global Id of the User","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"ID","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"todos","description":null,"args":[{"name":"after","description":"Only look at connected edges with cursors greater than the value of \u0060after\u0060.","type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null},{"name":"first","description":"Specifies the number of edges to return starting from \u0060after\u0060 or the first entry if \u0060after\u0060 is not specified.","type":{"kind":"SCALAR","name":"Int","ofType":null},"defaultValue":null},{"name":"status","description":"Filter todos by their status","type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":"\u0022any\u0022"}],"type":{"kind":"OBJECT","name":"TodoConnection","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"totalCount","description":null,"args":[],"type":{"kind":"SCALAR","name":"Int","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"completedCount","description":null,"args":[],"type":{"kind":"SCALAR","name":"Int","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[{"kind":"INTERFACE","name":"Node","ofType":null}],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"TodoConnection","description":"A connection from an object to a list of objects of type \u0060Todo\u0060.","fields":[{"name":"totalCount","description":"A count of the total number of objects in this connection, ignoring pagination. This allows a client to fetch the first five objects by passing \u00225\u0022 as the argument to \u0060first\u0060, then fetch the total count so it could display \u00225 of 83\u0022, for example. In cases where we employ infinite scrolling or don\u0027t have an exact count of entries, this field will return \u0060null\u0060.","args":[],"type":{"kind":"SCALAR","name":"Int","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"pageInfo","description":"Information to aid in pagination.","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"PageInfo","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"edges","description":"A list of all of the edges returned in the connection.","args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"OBJECT","name":"TodoEdge","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"items","description":"A list of all of the objects returned in the connection. This is a convenience field provided for quickly exploring the API; rather than querying for \u0022{ edges { node } }\u0022 when no edge data is needed, this field can be used instead. Note that when clients like Relay need to fetch the \u0022cursor\u0022 field on the edge to enable efficient pagination, this shortcut cannot be used, and the full \u0022{ edges { node } } \u0022 version should be used instead.","args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"OBJECT","name":"Todo","ofType":null}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"SCALAR","name":"Int","description":null,"fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"PageInfo","description":"Information about pagination in a connection.","fields":[{"name":"hasNextPage","description":"When paginating forwards, are there more items?","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"hasPreviousPage","description":"When paginating backwards, are there more items?","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"startCursor","description":"When paginating backwards, the cursor to continue.","args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"endCursor","description":"When paginating forwards, the cursor to continue.","args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"TodoEdge","description":"An edge in a connection from an object to another object of type \u0060Todo\u0060.","fields":[{"name":"cursor","description":"A cursor for use in pagination","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"node","description":"The item at the end of the edge","args":[],"type":{"kind":"OBJECT","name":"Todo","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"Todo","description":null,"fields":[{"name":"todoId","description":"The Id of the Todo","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"id","description":"The Global Id of the Todo","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"ID","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"text","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"complete","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[{"kind":"INTERFACE","name":"Node","ofType":null}],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"Mutation","description":null,"fields":[{"name":"addTodo","description":null,"args":[{"name":"input","description":null,"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"INPUT_OBJECT","name":"AddTodoInput","ofType":null}},"defaultValue":null}],"type":{"kind":"OBJECT","name":"AddTodoPayload","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"changeTodoStatus","description":null,"args":[{"name":"input","description":null,"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"INPUT_OBJECT","name":"ChangeTodoStatusInput","ofType":null}},"defaultValue":null}],"type":{"kind":"OBJECT","name":"ChangeTodoStatusPayload","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"markAllTodos","description":null,"args":[{"name":"input","description":null,"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"INPUT_OBJECT","name":"MarkAllTodosInput","ofType":null}},"defaultValue":null}],"type":{"kind":"OBJECT","name":"MarkAllTodosPayload","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"removeCompletedTodos","description":null,"args":[{"name":"input","description":null,"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"INPUT_OBJECT","name":"RemoveCompletedTodosInput","ofType":null}},"defaultValue":null}],"type":{"kind":"OBJECT","name":"RemoveCompletedTodosPayload","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"removeTodo","description":null,"args":[{"name":"input","description":null,"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"INPUT_OBJECT","name":"RemoveTodoInput","ofType":null}},"defaultValue":null}],"type":{"kind":"OBJECT","name":"RemoveTodoPayload","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"renameTodo","description":null,"args":[{"name":"input","description":null,"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"INPUT_OBJECT","name":"RenameTodoInput","ofType":null}},"defaultValue":null}],"type":{"kind":"OBJECT","name":"RenameTodoPayload","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"AddTodoPayload","description":null,"fields":[{"name":"clientMutationId","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"todoEdge","description":null,"args":[],"type":{"kind":"OBJECT","name":"TodoEdge","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"viewer","description":null,"args":[],"type":{"kind":"OBJECT","name":"User","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"INPUT_OBJECT","name":"AddTodoInput","description":null,"fields":null,"inputFields":[{"name":"clientMutationId","description":null,"type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null},{"name":"text","description":null,"type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null}],"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"ChangeTodoStatusPayload","description":null,"fields":[{"name":"clientMutationId","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"todo","description":null,"args":[],"type":{"kind":"OBJECT","name":"Todo","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"viewer","description":null,"args":[],"type":{"kind":"OBJECT","name":"User","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"INPUT_OBJECT","name":"ChangeTodoStatusInput","description":null,"fields":null,"inputFields":[{"name":"clientMutationId","description":null,"type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null},{"name":"id","description":null,"type":{"kind":"SCALAR","name":"ID","ofType":null},"defaultValue":null},{"name":"complete","description":null,"type":{"kind":"SCALAR","name":"Boolean","ofType":null},"defaultValue":null}],"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"MarkAllTodosPayload","description":null,"fields":[{"name":"clientMutationId","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"changedTodos","description":null,"args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"OBJECT","name":"Todo","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"viewer","description":null,"args":[],"type":{"kind":"OBJECT","name":"User","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"INPUT_OBJECT","name":"MarkAllTodosInput","description":null,"fields":null,"inputFields":[{"name":"clientMutationId","description":null,"type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null},{"name":"complete","description":null,"type":{"kind":"SCALAR","name":"Boolean","ofType":null},"defaultValue":null}],"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"RemoveCompletedTodosPayload","description":null,"fields":[{"name":"clientMutationId","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"deletedTodoIds","description":null,"args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"SCALAR","name":"ID","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"viewer","description":null,"args":[],"type":{"kind":"OBJECT","name":"User","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"INPUT_OBJECT","name":"RemoveCompletedTodosInput","description":null,"fields":null,"inputFields":[{"name":"clientMutationId","description":null,"type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null}],"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"RemoveTodoPayload","description":null,"fields":[{"name":"clientMutationId","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"deletedTodoId","description":null,"args":[],"type":{"kind":"SCALAR","name":"ID","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"viewer","description":null,"args":[],"type":{"kind":"OBJECT","name":"User","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"INPUT_OBJECT","name":"RemoveTodoInput","description":null,"fields":null,"inputFields":[{"name":"clientMutationId","description":null,"type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null},{"name":"id","description":null,"type":{"kind":"SCALAR","name":"ID","ofType":null},"defaultValue":null}],"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"RenameTodoPayload","description":null,"fields":[{"name":"clientMutationId","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"todo","description":null,"args":[],"type":{"kind":"OBJECT","name":"Todo","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"viewer","description":null,"args":[],"type":{"kind":"OBJECT","name":"User","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"INPUT_OBJECT","name":"RenameTodoInput","description":null,"fields":null,"inputFields":[{"name":"clientMutationId","description":null,"type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null},{"name":"id","description":null,"type":{"kind":"SCALAR","name":"ID","ofType":null},"defaultValue":null},{"name":"text","description":null,"type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null}],"interfaces":null,"enumValues":null,"possibleTypes":null}],"directives":[{"name":"include","description":"Directs the executor to include this field or fragment only when the \u0027if\u0027 argument is true.","locations":["FIELD","FRAGMENT_SPREAD","INLINE_FRAGMENT"],"args":[{"name":"if","description":"Included when true.","type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"defaultValue":null}]},{"name":"skip","description":"Directs the executor to skip this field or fragment when the \u0027if\u0027 argument is true.","locations":["FIELD","FRAGMENT_SPREAD","INLINE_FRAGMENT"],"args":[{"name":"if","description":"Skipped when true.","type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"defaultValue":null}]},{"name":"deprecated","description":"Marks an element of a GraphQL schema as no longer supported.","locations":["FIELD_DEFINITION","ENUM_VALUE"],"args":[{"name":"reason","description":"Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted in [Markdown](https://daringfireball.net/projects/markdown/).","type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":"\u0022No longer supported\u0022"}]}]}}} +======= +{"data":{"__schema":{"queryType":{"name":"Query"},"mutationType":{"name":"TodoMutation"},"subscriptionType":null,"types":[{"kind":"ENUM","name":"__DirectiveLocation","description":"A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.","fields":null,"inputFields":null,"interfaces":null,"enumValues":[{"name":"QUERY","description":"Location adjacent to a query operation.","isDeprecated":false,"deprecationReason":null},{"name":"MUTATION","description":"Location adjacent to a mutation operation.","isDeprecated":false,"deprecationReason":null},{"name":"SUBSCRIPTION","description":"Location adjacent to a subscription operation.","isDeprecated":false,"deprecationReason":null},{"name":"FIELD","description":"Location adjacent to a field.","isDeprecated":false,"deprecationReason":null},{"name":"FRAGMENT_DEFINITION","description":"Location adjacent to a fragment definition.","isDeprecated":false,"deprecationReason":null},{"name":"FRAGMENT_SPREAD","description":"Location adjacent to a fragment spread.","isDeprecated":false,"deprecationReason":null},{"name":"INLINE_FRAGMENT","description":"Location adjacent to an inline fragment.","isDeprecated":false,"deprecationReason":null},{"name":"SCHEMA","description":"Location adjacent to a schema definition.","isDeprecated":false,"deprecationReason":null},{"name":"SCALAR","description":"Location adjacent to a scalar definition.","isDeprecated":false,"deprecationReason":null},{"name":"OBJECT","description":"Location adjacent to an object type definition.","isDeprecated":false,"deprecationReason":null},{"name":"FIELD_DEFINITION","description":"Location adjacent to a field definition.","isDeprecated":false,"deprecationReason":null},{"name":"ARGUMENT_DEFINITION","description":"Location adjacent to an argument definition.","isDeprecated":false,"deprecationReason":null},{"name":"INTERFACE","description":"Location adjacent to an interface definition.","isDeprecated":false,"deprecationReason":null},{"name":"UNION","description":"Location adjacent to a union definition.","isDeprecated":false,"deprecationReason":null},{"name":"ENUM","description":"Location adjacent to an enum definition","isDeprecated":false,"deprecationReason":null},{"name":"ENUM_VALUE","description":"Location adjacent to an enum value definition","isDeprecated":false,"deprecationReason":null},{"name":"INPUT_OBJECT","description":"Location adjacent to an input object type definition.","isDeprecated":false,"deprecationReason":null},{"name":"INPUT_FIELD_DEFINITION","description":"Location adjacent to an input object field definition.","isDeprecated":false,"deprecationReason":null}],"possibleTypes":null},{"kind":"ENUM","name":"__TypeKind","description":"An enum describing what kind of type a given __Type is.","fields":null,"inputFields":null,"interfaces":null,"enumValues":[{"name":"SCALAR","description":"Indicates this type is a scalar.","isDeprecated":false,"deprecationReason":null},{"name":"OBJECT","description":"Indicates this type is an object. \u0060fields\u0060 and \u0060possibleTypes\u0060 are valid fields.","isDeprecated":false,"deprecationReason":null},{"name":"INTERFACE","description":"Indicates this type is an interface. \u0060fields\u0060 and \u0060possibleTypes\u0060 are valid fields.","isDeprecated":false,"deprecationReason":null},{"name":"UNION","description":"Indicates this type is a union. \u0060possibleTypes\u0060 is a valid field.","isDeprecated":false,"deprecationReason":null},{"name":"ENUM","description":"Indicates this type is an enum. \u0060enumValues\u0060 is a valid field.","isDeprecated":false,"deprecationReason":null},{"name":"INPUT_OBJECT","description":"Indicates this type is an input object. \u0060inputFields\u0060 is a valid field.","isDeprecated":false,"deprecationReason":null},{"name":"LIST","description":"Indicates this type is a list. \u0060ofType\u0060 is a valid field.","isDeprecated":false,"deprecationReason":null},{"name":"NON_NULL","description":"Indicates this type is a non-null. \u0060ofType\u0060 is a valid field.","isDeprecated":false,"deprecationReason":null}],"possibleTypes":null},{"kind":"OBJECT","name":"__EnumValue","description":"One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.","fields":[{"name":"name","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"isDeprecated","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"deprecationReason","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"SCALAR","name":"String","description":null,"fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"SCALAR","name":"Boolean","description":null,"fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__Directive","description":"A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL\u0027s execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.","fields":[{"name":"name","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"locations","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"ENUM","name":"__DirectiveLocation","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"args","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__InputValue","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"onOperation","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":true,"deprecationReason":"Use \u0027locations\u0027."},{"name":"onFragment","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":true,"deprecationReason":"Use \u0027locations\u0027."},{"name":"onField","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":true,"deprecationReason":"Use \u0027locations\u0027."}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__InputValue","description":"Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.","fields":[{"name":"name","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"type","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"defaultValue","description":"A GraphQL-formatted string representing the default value for this input value.","args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__Type","description":"The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the \u0060__TypeKind\u0060 enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name and description, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.","fields":[{"name":"kind","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"ENUM","name":"__TypeKind","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"name","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"fields","description":null,"args":[{"name":"includeDeprecated","description":null,"type":{"kind":"SCALAR","name":"Boolean","ofType":null},"defaultValue":"false"}],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Field","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"interfaces","description":null,"args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"possibleTypes","description":null,"args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"enumValues","description":null,"args":[{"name":"includeDeprecated","description":null,"type":{"kind":"SCALAR","name":"Boolean","ofType":null},"defaultValue":"false"}],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__EnumValue","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"inputFields","description":null,"args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__InputValue","ofType":null}}},"isDeprecated":false,"deprecationReason":null},{"name":"ofType","description":null,"args":[],"type":{"kind":"OBJECT","name":"__Type","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__Field","description":"Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.","fields":[{"name":"name","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"args","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__InputValue","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"type","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"isDeprecated","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"deprecationReason","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"__Schema","description":"A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.","fields":[{"name":"description","description":null,"args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"types","description":"A list of all types supported by this server.","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}}}},"isDeprecated":false,"deprecationReason":null},{"name":"queryType","description":"The type that query operations will be rooted at.","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Type","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"mutationType","description":"If this server supports mutation, the type that mutation operations will be rooted at.","args":[],"type":{"kind":"OBJECT","name":"__Type","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"subscriptionType","description":"If this server supports subscription, the type that subscription operations will be rooted at.","args":[],"type":{"kind":"OBJECT","name":"__Type","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"directives","description":"A list of all directives supported by this server.","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"LIST","name":null,"ofType":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"__Directive","ofType":null}}}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"Query","description":null,"fields":[{"name":"node","description":"Fetches an object given its global Id","args":[{"name":"id","description":"The global Id of the object","type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"ID","ofType":null}},"defaultValue":null}],"type":{"kind":"INTERFACE","name":"Node","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"viewer","description":null,"args":[],"type":{"kind":"OBJECT","name":"User","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"INTERFACE","name":"Node","description":null,"fields":[{"name":"id","description":"Global node Id","args":[],"type":{"kind":"SCALAR","name":"ID","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":[{"kind":"OBJECT","name":"Todo","ofType":null},{"kind":"OBJECT","name":"User","ofType":null}]},{"kind":"SCALAR","name":"ID","description":null,"fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"User","description":null,"fields":[{"name":"userId","description":"The Id of the User","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"id","description":"The Global Id of the User","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"ID","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"todos","description":null,"args":[{"name":"after","description":"Only return edges after the specified cursor.","type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null},{"name":"first","description":"Specifies the maximum number of edges to return, starting after the cursor specified by \u0027after\u0027, or the first number of edges if \u0027after\u0027 is not specified.","type":{"kind":"SCALAR","name":"Int","ofType":null},"defaultValue":null},{"name":"status","description":"Filter todos by their status","type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":"\u0022any\u0022"}],"type":{"kind":"OBJECT","name":"TodoConnection","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"totalCount","description":null,"args":[],"type":{"kind":"SCALAR","name":"Int","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"completedCount","description":null,"args":[],"type":{"kind":"SCALAR","name":"Int","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[{"kind":"INTERFACE","name":"Node","ofType":null}],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"TodoConnection","description":"A connection from an object to a list of objects of type \u0060Todo\u0060.","fields":[{"name":"totalCount","description":"A count of the total number of objects in this connection, ignoring pagination. This allows a client to fetch the first five objects by passing \u00225\u0022 as the argument to \u0060first\u0060, then fetch the total count so it could display \u00225 of 83\u0022, for example. In cases where we employ infinite scrolling or don\u0027t have an exact count of entries, this field will return \u0060null\u0060.","args":[],"type":{"kind":"SCALAR","name":"Int","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"pageInfo","description":"Information to aid in pagination.","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"OBJECT","name":"PageInfo","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"edges","description":"A list of all of the edges returned in the connection.","args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"OBJECT","name":"TodoEdge","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"items","description":"A list of all of the objects returned in the connection. This is a convenience field provided for quickly exploring the API; rather than querying for \u0022{ edges { node } }\u0022 when no edge data is needed, this field can be used instead. Note that when clients like Relay need to fetch the \u0022cursor\u0022 field on the edge to enable efficient pagination, this shortcut cannot be used, and the full \u0022{ edges { node } } \u0022 version should be used instead.","args":[],"type":{"kind":"LIST","name":null,"ofType":{"kind":"OBJECT","name":"Todo","ofType":null}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"SCALAR","name":"Int","description":null,"fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"PageInfo","description":"Information about pagination in a connection.","fields":[{"name":"hasNextPage","description":"When paginating forwards, are there more items?","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"hasPreviousPage","description":"When paginating backwards, are there more items?","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"startCursor","description":"When paginating backwards, the cursor to continue.","args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"endCursor","description":"When paginating forwards, the cursor to continue.","args":[],"type":{"kind":"SCALAR","name":"String","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"TodoEdge","description":"An edge in a connection from an object to another object of type \u0060Todo\u0060.","fields":[{"name":"cursor","description":"A cursor for use in pagination","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"node","description":"The item at the end of the edge","args":[],"type":{"kind":"OBJECT","name":"Todo","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"Todo","description":null,"fields":[{"name":"todoId","description":"The Id of the Todo","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"id","description":"The Global Id of the Todo","args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"ID","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"text","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"String","ofType":null}},"isDeprecated":false,"deprecationReason":null},{"name":"complete","description":null,"args":[],"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[{"kind":"INTERFACE","name":"Node","ofType":null}],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"TodoMutation","description":null,"fields":[{"name":"addTodo","description":null,"args":[{"name":"input","description":null,"type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"INPUT_OBJECT","name":"AddTodoInput","ofType":null}},"defaultValue":null}],"type":{"kind":"OBJECT","name":"AddTodoPayload","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"OBJECT","name":"AddTodoPayload","description":null,"fields":[{"name":"todoEdge","description":null,"args":[],"type":{"kind":"OBJECT","name":"TodoEdge","ofType":null},"isDeprecated":false,"deprecationReason":null},{"name":"viewer","description":null,"args":[],"type":{"kind":"OBJECT","name":"User","ofType":null},"isDeprecated":false,"deprecationReason":null}],"inputFields":null,"interfaces":[],"enumValues":null,"possibleTypes":null},{"kind":"INPUT_OBJECT","name":"AddTodoInput","description":null,"fields":null,"inputFields":[{"name":"text","description":null,"type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":null}],"interfaces":null,"enumValues":null,"possibleTypes":null}],"directives":[{"name":"include","description":"Directs the executor to include this field or fragment only when the \u0027if\u0027 argument is true.","locations":["FIELD","FRAGMENT_SPREAD","INLINE_FRAGMENT"],"args":[{"name":"if","description":"Included when true.","type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"defaultValue":null}]},{"name":"skip","description":"Directs the executor to skip this field or fragment when the \u0027if\u0027 argument is true.","locations":["FIELD","FRAGMENT_SPREAD","INLINE_FRAGMENT"],"args":[{"name":"if","description":"Skipped when true.","type":{"kind":"NON_NULL","name":null,"ofType":{"kind":"SCALAR","name":"Boolean","ofType":null}},"defaultValue":null}]},{"name":"deprecated","description":"Marks an element of a GraphQL schema as no longer supported.","locations":["FIELD_DEFINITION","ENUM_VALUE"],"args":[{"name":"reason","description":"Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted in [Markdown](https://daringfireball.net/projects/markdown/).","type":{"kind":"SCALAR","name":"String","ofType":null},"defaultValue":"\u0022No longer supported\u0022"}]}]}}} +>>>>>>> Stashed changes diff --git a/src/GraphQL.Relay/GraphQL.Relay.csproj b/src/GraphQL.Relay/GraphQL.Relay.csproj index c231f2b8a..6ab956c70 100644 --- a/src/GraphQL.Relay/GraphQL.Relay.csproj +++ b/src/GraphQL.Relay/GraphQL.Relay.csproj @@ -1,6 +1,6 @@  - netstandard2.0 + net5 GraphQL;Relay;React diff --git a/src/GraphQL.Relay/Types/MutationInputs.cs b/src/GraphQL.Relay/Types/MutationInputs.cs deleted file mode 100644 index c723bb1ca..000000000 --- a/src/GraphQL.Relay/Types/MutationInputs.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Collections.Generic; - -namespace GraphQL.Relay.Types -{ - public class MutationInputs : Dictionary - { - public MutationInputs() - { - } - - public MutationInputs(IDictionary dict) : base(dict) - { - } - - public object Get(string key) - { - return this[key]; - } - - public T Get(string key, T defaultValue = default(T)) - { - object value; - if (!TryGetValue(key, out value)) - return defaultValue; - - return (T) value; - } - } -} \ No newline at end of file diff --git a/src/GraphQL.Relay/Types/MutationPayloadGraphType.cs b/src/GraphQL.Relay/Types/MutationPayloadGraphType.cs deleted file mode 100644 index e8f991b26..000000000 --- a/src/GraphQL.Relay/Types/MutationPayloadGraphType.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using GraphQL.Language.AST; -using GraphQL.Types; - -namespace GraphQL.Relay.Types -{ - public interface IMutationPayload - { - T MutateAndGetPayload(MutationInputs inputs, IResolveFieldContext context); - } - - - public abstract class MutationPayloadGraphType : ObjectGraphType, IMutationPayload - { - protected MutationPayloadGraphType() - { - Field( - name: "clientMutationId", - type: typeof(StringGraphType), - resolve: GetClientId); - } - - public abstract TOut MutateAndGetPayload(MutationInputs inputs, IResolveFieldContext context); - - private string GetClientId(IResolveFieldContext context) - { - var field = context.Operation.SelectionSet.Selections - .Where(s => s is Field) - .Cast() - .First(s => IsCorrectSelection(context, s)); - - var arg = field.Arguments.First(a => a.Name == "input"); - - if (arg.Value is VariableReference) - { - var name = ((VariableReference)arg.Value).Name; - var inputs = context.Variables.First(v => v.Name == name).Value as Dictionary; - - return inputs["clientMutationId"] as string; - } - - var value = - ((ObjectValue)arg.Value).ObjectFields.First(f => f.Name == "clientMutationId").Value as StringValue; - return value.Value; - } - - private bool IsCorrectSelection(IResolveFieldContext context, Field field) - { - return Enumerable.Any(field.SelectionSet.Selections, - s => s.SourceLocation.Equals(context.FieldAst.SourceLocation)); - } - } - - - public abstract class MutationPayloadGraphType : MutationPayloadGraphType - { - } - - public abstract class MutationPayloadGraphType : MutationPayloadGraphType - { - } -} \ No newline at end of file From b063384977283e9915408d1da1645682d6c500f8 Mon Sep 17 00:00:00 2001 From: Fiyaz Bin Hasan Date: Wed, 14 Jul 2021 15:33:30 +0600 Subject: [PATCH 2/6] lot of refactoring --- .../GraphQL.Relay.Todo.csproj | 52 ------------------- 1 file changed, 52 deletions(-) diff --git a/src/GraphQL.Relay.Todo/GraphQL.Relay.Todo.csproj b/src/GraphQL.Relay.Todo/GraphQL.Relay.Todo.csproj index c2df578d8..80108601f 100644 --- a/src/GraphQL.Relay.Todo/GraphQL.Relay.Todo.csproj +++ b/src/GraphQL.Relay.Todo/GraphQL.Relay.Todo.csproj @@ -1,7 +1,6 @@  -<<<<<<< Updated upstream net5 $(NoWarn);1591;IDE1006 @@ -10,59 +9,8 @@ -======= - net6.0 - true - Latest - false - ClientApp\ - $(DefaultItemExcludes);$(SpaRoot)node_modules\** - http://localhost:5002 - npm start - - - - - - - - - - - - ->>>>>>> Stashed changes - - - - - - - - - - - - - - - - - - - - - - - wwwroot\%(RecursiveDir)%(FileName)%(Extension) - PreserveNewest - true - - - - From 77f604d45fe4723dd0bf83e9eb4188e5bc457a3a Mon Sep 17 00:00:00 2001 From: Fiyaz Bin Hasan Date: Wed, 14 Jul 2021 16:39:28 +0600 Subject: [PATCH 3/6] massive refactoring --- Project1/.gitignore | 232 + Project1/ClientApp/.env | 1 + Project1/ClientApp/.env.development | 1 + Project1/ClientApp/README.md | 2228 +++ Project1/ClientApp/package-lock.json | 16656 ++++++++++++++++ Project1/ClientApp/package.json | 55 + Project1/ClientApp/public/favicon.ico | Bin 0 -> 5430 bytes Project1/ClientApp/public/index.html | 41 + Project1/ClientApp/public/manifest.json | 15 + Project1/ClientApp/src/App.js | 22 + .../ClientApp/src/App.test.js | 0 Project1/ClientApp/src/components/Counter.js | 31 + .../ClientApp/src/components/FetchData.js | 59 + Project1/ClientApp/src/components/Home.js | 26 + Project1/ClientApp/src/components/Layout.js | 18 + Project1/ClientApp/src/components/NavMenu.css | 18 + Project1/ClientApp/src/components/NavMenu.js | 49 + Project1/ClientApp/src/custom.css | 14 + Project1/ClientApp/src/index.js | 18 + .../ClientApp/src/registerServiceWorker.js | 108 + Project1/ClientApp/src/setupProxy.js | 14 + .../Controllers/WeatherForecastController.cs | 2 +- Project1/Pages/Error.cshtml | 26 + Project1/Pages/Error.cshtml.cs | 31 + Project1/Pages/_ViewImports.cshtml | 3 + Project1/Program.cs | 26 + Project1/Project1.csproj | 57 + Project1/Properties/launchSettings.json | 30 + Project1/Startup.cs | 50 + .../WeatherForecast.cs | 2 +- Project1/appsettings.Development.json | 10 + Project1/appsettings.json | 10 + .../__generated__/appQuery.graphql.js | 331 - src/GraphQL.Relay.Todo/ClientApp/app.js | 79 - .../ClientApp/components/TodoList.js | 78 - .../ClientApp/components/TodoListFooter.js | 69 - .../ClientApp/components/TodoTextInput.js | 79 - .../__generated__/Todo_todo.graphql.js | 50 - .../__generated__/Todo_viewer.graphql.js | 50 - src/GraphQL.Relay.Todo/ClientApp/css/base.css | 141 - .../ClientApp/css/index.css | 370 - .../ClientApp/mutations/AddTodoMutation.js | 92 - .../mutations/ChangeTodoStatusMutation.js | 58 - .../mutations/MarkAllTodosMutation.js | 58 - .../mutations/RemoveCompletedTodosMutation.js | 70 - .../ClientApp/mutations/RemoveTodoMutation.js | 50 - .../ClientApp/mutations/RenameTodoMutation.js | 47 - .../ChangeTodoStatusMutation.graphql.js | 234 - .../MarkAllTodosMutation.graphql.js | 225 - .../RemoveCompletedTodosMutation.graphql.js | 190 - .../RemoveTodoMutation.graphql.js | 191 - .../RenameTodoMutation.graphql.js | 168 - .../ClientApp/public/index.html | 12 +- src/GraphQL.Relay.Todo/ClientApp/src/App.js | 6 - .../src/__generated__/AppQuery.graphql.js | 217 +- .../ClientApp/src/components/Header.js | 21 - .../ClientApp/src/components/Link.js | 26 - .../ClientApp/src/components/MainSection.js | 40 - .../ClientApp/{ => src}/components/Todo.js | 0 .../ClientApp/src/components/TodoApp.js | 115 +- .../ClientApp/src/components/TodoItem.js | 63 - .../ClientApp/src/components/TodoList.js | 91 +- .../src/components/TodoListFooter.js | 96 +- .../ClientApp/src/components/TodoTextInput.js | 119 +- .../__generated__/TodoApp_viewer.graphql.js | 43 +- .../TodoListFooter_viewer.graphql.js | 78 +- .../__generated__/TodoList_viewer.graphql.js | 98 +- .../__generated__/Todo_todo.graphql.js | 63 + .../__generated__/Todo_viewer.graphql.js | 63 + .../__generated__/AddTodoMutation.graphql.js | 296 +- .../Database/TodoDatabase.cs | 64 +- .../GraphQL.Relay.Todo.csproj | 50 +- src/GraphQL.Relay.Todo/Program.cs | 18 - .../Properties/launchSettings.json | 5 - src/GraphQL.Relay.Todo/Schema/Mutation.cs | 429 +- src/GraphQL.Relay.Todo/Schema/Query.cs | 9 - src/GraphQL.Relay.Todo/Schema/TodoSchema.cs | 10 - src/GraphQL.Relay.Todo/SchemaWriter.cs | 9 +- src/GraphQL.Relay.Todo/Startup.cs | 22 - src/GraphQL.Relay.Todo/appsettings.json | 8 +- src/GraphQL.Relay.Todo/package.json | 29 - src/GraphQL.Relay.Todo/webpack.config.js | 27 - src/GraphQL.Relay.Todo/wwwroot/index.html | 8 +- src/GraphQL.Relay.Todo/wwwroot/schema.json | 6 +- src/GraphQL.Relay.Todo/yarn.lock | 5522 ----- src/GraphQL.Relay/Types/MutationGraphType.cs | 31 - .../Types/MutationInputGraphType.cs | 12 - 87 files changed, 20722 insertions(+), 9467 deletions(-) create mode 100644 Project1/.gitignore create mode 100644 Project1/ClientApp/.env create mode 100644 Project1/ClientApp/.env.development create mode 100644 Project1/ClientApp/README.md create mode 100644 Project1/ClientApp/package-lock.json create mode 100644 Project1/ClientApp/package.json create mode 100644 Project1/ClientApp/public/favicon.ico create mode 100644 Project1/ClientApp/public/index.html create mode 100644 Project1/ClientApp/public/manifest.json create mode 100644 Project1/ClientApp/src/App.js rename {src/GraphQL.Relay.Todo => Project1}/ClientApp/src/App.test.js (100%) create mode 100644 Project1/ClientApp/src/components/Counter.js create mode 100644 Project1/ClientApp/src/components/FetchData.js create mode 100644 Project1/ClientApp/src/components/Home.js create mode 100644 Project1/ClientApp/src/components/Layout.js create mode 100644 Project1/ClientApp/src/components/NavMenu.css create mode 100644 Project1/ClientApp/src/components/NavMenu.js create mode 100644 Project1/ClientApp/src/custom.css create mode 100644 Project1/ClientApp/src/index.js create mode 100644 Project1/ClientApp/src/registerServiceWorker.js create mode 100644 Project1/ClientApp/src/setupProxy.js rename {src/GraphQL.Relay.Todo => Project1}/Controllers/WeatherForecastController.cs (96%) create mode 100644 Project1/Pages/Error.cshtml create mode 100644 Project1/Pages/Error.cshtml.cs create mode 100644 Project1/Pages/_ViewImports.cshtml create mode 100644 Project1/Program.cs create mode 100644 Project1/Project1.csproj create mode 100644 Project1/Properties/launchSettings.json create mode 100644 Project1/Startup.cs rename {src/GraphQL.Relay.Todo => Project1}/WeatherForecast.cs (90%) create mode 100644 Project1/appsettings.Development.json create mode 100644 Project1/appsettings.json delete mode 100644 src/GraphQL.Relay.Todo/ClientApp/__generated__/appQuery.graphql.js delete mode 100644 src/GraphQL.Relay.Todo/ClientApp/app.js delete mode 100644 src/GraphQL.Relay.Todo/ClientApp/components/TodoList.js delete mode 100644 src/GraphQL.Relay.Todo/ClientApp/components/TodoListFooter.js delete mode 100644 src/GraphQL.Relay.Todo/ClientApp/components/TodoTextInput.js delete mode 100644 src/GraphQL.Relay.Todo/ClientApp/components/__generated__/Todo_todo.graphql.js delete mode 100644 src/GraphQL.Relay.Todo/ClientApp/components/__generated__/Todo_viewer.graphql.js delete mode 100644 src/GraphQL.Relay.Todo/ClientApp/css/base.css delete mode 100644 src/GraphQL.Relay.Todo/ClientApp/css/index.css delete mode 100644 src/GraphQL.Relay.Todo/ClientApp/mutations/AddTodoMutation.js delete mode 100644 src/GraphQL.Relay.Todo/ClientApp/mutations/ChangeTodoStatusMutation.js delete mode 100644 src/GraphQL.Relay.Todo/ClientApp/mutations/MarkAllTodosMutation.js delete mode 100644 src/GraphQL.Relay.Todo/ClientApp/mutations/RemoveCompletedTodosMutation.js delete mode 100644 src/GraphQL.Relay.Todo/ClientApp/mutations/RemoveTodoMutation.js delete mode 100644 src/GraphQL.Relay.Todo/ClientApp/mutations/RenameTodoMutation.js delete mode 100644 src/GraphQL.Relay.Todo/ClientApp/mutations/__generated__/ChangeTodoStatusMutation.graphql.js delete mode 100644 src/GraphQL.Relay.Todo/ClientApp/mutations/__generated__/MarkAllTodosMutation.graphql.js delete mode 100644 src/GraphQL.Relay.Todo/ClientApp/mutations/__generated__/RemoveCompletedTodosMutation.graphql.js delete mode 100644 src/GraphQL.Relay.Todo/ClientApp/mutations/__generated__/RemoveTodoMutation.graphql.js delete mode 100644 src/GraphQL.Relay.Todo/ClientApp/mutations/__generated__/RenameTodoMutation.graphql.js delete mode 100644 src/GraphQL.Relay.Todo/ClientApp/src/components/Header.js delete mode 100644 src/GraphQL.Relay.Todo/ClientApp/src/components/Link.js delete mode 100644 src/GraphQL.Relay.Todo/ClientApp/src/components/MainSection.js rename src/GraphQL.Relay.Todo/ClientApp/{ => src}/components/Todo.js (100%) delete mode 100644 src/GraphQL.Relay.Todo/ClientApp/src/components/TodoItem.js rename src/GraphQL.Relay.Todo/ClientApp/{ => src}/components/__generated__/TodoListFooter_viewer.graphql.js (60%) rename src/GraphQL.Relay.Todo/ClientApp/{ => src}/components/__generated__/TodoList_viewer.graphql.js (72%) create mode 100644 src/GraphQL.Relay.Todo/ClientApp/src/components/__generated__/Todo_todo.graphql.js create mode 100644 src/GraphQL.Relay.Todo/ClientApp/src/components/__generated__/Todo_viewer.graphql.js delete mode 100644 src/GraphQL.Relay.Todo/package.json delete mode 100644 src/GraphQL.Relay.Todo/webpack.config.js delete mode 100644 src/GraphQL.Relay.Todo/yarn.lock delete mode 100644 src/GraphQL.Relay/Types/MutationGraphType.cs delete mode 100644 src/GraphQL.Relay/Types/MutationInputGraphType.cs diff --git a/Project1/.gitignore b/Project1/.gitignore new file mode 100644 index 000000000..8f8b43bb1 --- /dev/null +++ b/Project1/.gitignore @@ -0,0 +1,232 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +bin/ +Bin/ +obj/ +Obj/ + +# Visual Studio 2015 cache/options directory +.vs/ +/wwwroot/dist/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Microsoft Azure ApplicationInsights config file +ApplicationInsights.config + +# Windows Store app package directory +AppPackages/ +BundleArtifacts/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +orleans.codegen.cs + +/node_modules + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe + +# FAKE - F# Make +.fake/ diff --git a/Project1/ClientApp/.env b/Project1/ClientApp/.env new file mode 100644 index 000000000..6ce384e5c --- /dev/null +++ b/Project1/ClientApp/.env @@ -0,0 +1 @@ +BROWSER=none diff --git a/Project1/ClientApp/.env.development b/Project1/ClientApp/.env.development new file mode 100644 index 000000000..2dcec8bed --- /dev/null +++ b/Project1/ClientApp/.env.development @@ -0,0 +1 @@ +PORT=5002 diff --git a/Project1/ClientApp/README.md b/Project1/ClientApp/README.md new file mode 100644 index 000000000..5a608cbdc --- /dev/null +++ b/Project1/ClientApp/README.md @@ -0,0 +1,2228 @@ +This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app). + +Below you will find some information on how to perform common tasks.
+You can find the most recent version of this guide [here](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md). + +## Table of Contents + +- [Updating to New Releases](#updating-to-new-releases) +- [Sending Feedback](#sending-feedback) +- [Folder Structure](#folder-structure) +- [Available Scripts](#available-scripts) + - [npm start](#npm-start) + - [npm test](#npm-test) + - [npm run build](#npm-run-build) + - [npm run eject](#npm-run-eject) +- [Supported Language Features and Polyfills](#supported-language-features-and-polyfills) +- [Syntax Highlighting in the Editor](#syntax-highlighting-in-the-editor) +- [Displaying Lint Output in the Editor](#displaying-lint-output-in-the-editor) +- [Debugging in the Editor](#debugging-in-the-editor) +- [Formatting Code Automatically](#formatting-code-automatically) +- [Changing the Page ``](#changing-the-page-title) +- [Installing a Dependency](#installing-a-dependency) +- [Importing a Component](#importing-a-component) +- [Code Splitting](#code-splitting) +- [Adding a Stylesheet](#adding-a-stylesheet) +- [Post-Processing CSS](#post-processing-css) +- [Adding a CSS Preprocessor (Sass, Less etc.)](#adding-a-css-preprocessor-sass-less-etc) +- [Adding Images, Fonts, and Files](#adding-images-fonts-and-files) +- [Using the `public` Folder](#using-the-public-folder) + - [Changing the HTML](#changing-the-html) + - [Adding Assets Outside of the Module System](#adding-assets-outside-of-the-module-system) + - [When to Use the `public` Folder](#when-to-use-the-public-folder) +- [Using Global Variables](#using-global-variables) +- [Adding Bootstrap](#adding-bootstrap) + - [Using a Custom Theme](#using-a-custom-theme) +- [Adding Flow](#adding-flow) +- [Adding Custom Environment Variables](#adding-custom-environment-variables) + - [Referencing Environment Variables in the HTML](#referencing-environment-variables-in-the-html) + - [Adding Temporary Environment Variables In Your Shell](#adding-temporary-environment-variables-in-your-shell) + - [Adding Development Environment Variables In `.env`](#adding-development-environment-variables-in-env) +- [Can I Use Decorators?](#can-i-use-decorators) +- [Integrating with an API Backend](#integrating-with-an-api-backend) + - [Node](#node) + - [Ruby on Rails](#ruby-on-rails) +- [Proxying API Requests in Development](#proxying-api-requests-in-development) + - ["Invalid Host Header" Errors After Configuring Proxy](#invalid-host-header-errors-after-configuring-proxy) + - [Configuring the Proxy Manually](#configuring-the-proxy-manually) + - [Configuring a WebSocket Proxy](#configuring-a-websocket-proxy) +- [Using HTTPS in Development](#using-https-in-development) +- [Generating Dynamic `<meta>` Tags on the Server](#generating-dynamic-meta-tags-on-the-server) +- [Pre-Rendering into Static HTML Files](#pre-rendering-into-static-html-files) +- [Injecting Data from the Server into the Page](#injecting-data-from-the-server-into-the-page) +- [Running Tests](#running-tests) + - [Filename Conventions](#filename-conventions) + - [Command Line Interface](#command-line-interface) + - [Version Control Integration](#version-control-integration) + - [Writing Tests](#writing-tests) + - [Testing Components](#testing-components) + - [Using Third Party Assertion Libraries](#using-third-party-assertion-libraries) + - [Initializing Test Environment](#initializing-test-environment) + - [Focusing and Excluding Tests](#focusing-and-excluding-tests) + - [Coverage Reporting](#coverage-reporting) + - [Continuous Integration](#continuous-integration) + - [Disabling jsdom](#disabling-jsdom) + - [Snapshot Testing](#snapshot-testing) + - [Editor Integration](#editor-integration) +- [Developing Components in Isolation](#developing-components-in-isolation) + - [Getting Started with Storybook](#getting-started-with-storybook) + - [Getting Started with Styleguidist](#getting-started-with-styleguidist) +- [Making a Progressive Web App](#making-a-progressive-web-app) + - [Opting Out of Caching](#opting-out-of-caching) + - [Offline-First Considerations](#offline-first-considerations) + - [Progressive Web App Metadata](#progressive-web-app-metadata) +- [Analyzing the Bundle Size](#analyzing-the-bundle-size) +- [Deployment](#deployment) + - [Static Server](#static-server) + - [Other Solutions](#other-solutions) + - [Serving Apps with Client-Side Routing](#serving-apps-with-client-side-routing) + - [Building for Relative Paths](#building-for-relative-paths) + - [Azure](#azure) + - [Firebase](#firebase) + - [GitHub Pages](#github-pages) + - [Heroku](#heroku) + - [Netlify](#netlify) + - [Now](#now) + - [S3 and CloudFront](#s3-and-cloudfront) + - [Surge](#surge) +- [Advanced Configuration](#advanced-configuration) +- [Troubleshooting](#troubleshooting) + - [`npm start` doesn’t detect changes](#npm-start-doesnt-detect-changes) + - [`npm test` hangs on macOS Sierra](#npm-test-hangs-on-macos-sierra) + - [`npm run build` exits too early](#npm-run-build-exits-too-early) + - [`npm run build` fails on Heroku](#npm-run-build-fails-on-heroku) + - [`npm run build` fails to minify](#npm-run-build-fails-to-minify) + - [Moment.js locales are missing](#momentjs-locales-are-missing) +- [Something Missing?](#something-missing) + +## Updating to New Releases + +Create React App is divided into two packages: + +* `create-react-app` is a global command-line utility that you use to create new projects. +* `react-scripts` is a development dependency in the generated projects (including this one). + +You almost never need to update `create-react-app` itself: it delegates all the setup to `react-scripts`. + +When you run `create-react-app`, it always creates the project with the latest version of `react-scripts` so you’ll get all the new features and improvements in newly created apps automatically. + +To update an existing project to a new version of `react-scripts`, [open the changelog](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md), find the version you’re currently on (check `package.json` in this folder if you’re not sure), and apply the migration instructions for the newer versions. + +In most cases bumping the `react-scripts` version in `package.json` and running `npm install` in this folder should be enough, but it’s good to consult the [changelog](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md) for potential breaking changes. + +We commit to keeping the breaking changes minimal so you can upgrade `react-scripts` painlessly. + +## Sending Feedback + +We are always open to [your feedback](https://github.com/facebookincubator/create-react-app/issues). + +## Folder Structure + +After creation, your project should look like this: + +``` +my-app/ + README.md + node_modules/ + package.json + public/ + index.html + favicon.ico + src/ + App.css + App.js + App.test.js + index.css + index.js + logo.svg +``` + +For the project to build, **these files must exist with exact filenames**: + +* `public/index.html` is the page template; +* `src/index.js` is the JavaScript entry point. + +You can delete or rename the other files. + +You may create subdirectories inside `src`. For faster rebuilds, only files inside `src` are processed by Webpack.<br> +You need to **put any JS and CSS files inside `src`**, otherwise Webpack won’t see them. + +Only files inside `public` can be used from `public/index.html`.<br> +Read instructions below for using assets from JavaScript and HTML. + +You can, however, create more top-level directories.<br> +They will not be included in the production build so you can use them for things like documentation. + +## Available Scripts + +In the project directory, you can run: + +### `npm start` + +Runs the app in the development mode.<br> +Open [http://localhost:3000](http://localhost:3000) to view it in the browser. + +The page will reload if you make edits.<br> +You will also see any lint errors in the console. + +### `npm test` + +Launches the test runner in the interactive watch mode.<br> +See the section about [running tests](#running-tests) for more information. + +### `npm run build` + +Builds the app for production to the `build` folder.<br> +It correctly bundles React in production mode and optimizes the build for the best performance. + +The build is minified and the filenames include the hashes.<br> +Your app is ready to be deployed! + +See the section about [deployment](#deployment) for more information. + +### `npm run eject` + +**Note: this is a one-way operation. Once you `eject`, you can’t go back!** + +If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. + +Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. + +You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. + +## Supported Language Features and Polyfills + +This project supports a superset of the latest JavaScript standard.<br> +In addition to [ES6](https://github.com/lukehoban/es6features) syntax features, it also supports: + +* [Exponentiation Operator](https://github.com/rwaldron/exponentiation-operator) (ES2016). +* [Async/await](https://github.com/tc39/ecmascript-asyncawait) (ES2017). +* [Object Rest/Spread Properties](https://github.com/sebmarkbage/ecmascript-rest-spread) (stage 3 proposal). +* [Dynamic import()](https://github.com/tc39/proposal-dynamic-import) (stage 3 proposal) +* [Class Fields and Static Properties](https://github.com/tc39/proposal-class-public-fields) (part of stage 3 proposal). +* [JSX](https://facebook.github.io/react/docs/introducing-jsx.html) and [Flow](https://flowtype.org/) syntax. + +Learn more about [different proposal stages](https://babeljs.io/docs/plugins/#presets-stage-x-experimental-presets-). + +While we recommend using experimental proposals with some caution, Facebook heavily uses these features in the product code, so we intend to provide [codemods](https://medium.com/@cpojer/effective-javascript-codemods-5a6686bb46fb) if any of these proposals change in the future. + +Note that **the project only includes a few ES6 [polyfills](https://en.wikipedia.org/wiki/Polyfill)**: + +* [`Object.assign()`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) via [`object-assign`](https://github.com/sindresorhus/object-assign). +* [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) via [`promise`](https://github.com/then/promise). +* [`fetch()`](https://developer.mozilla.org/en/docs/Web/API/Fetch_API) via [`whatwg-fetch`](https://github.com/github/fetch). + +If you use any other ES6+ features that need **runtime support** (such as `Array.from()` or `Symbol`), make sure you are including the appropriate polyfills manually, or that the browsers you are targeting already support them. + +## Syntax Highlighting in the Editor + +To configure the syntax highlighting in your favorite text editor, head to the [relevant Babel documentation page](https://babeljs.io/docs/editors) and follow the instructions. Some of the most popular editors are covered. + +## Displaying Lint Output in the Editor + +>Note: this feature is available with `react-scripts@0.2.0` and higher.<br> +>It also only works with npm 3 or higher. + +Some editors, including Sublime Text, Atom, and Visual Studio Code, provide plugins for ESLint. + +They are not required for linting. You should see the linter output right in your terminal as well as the browser console. However, if you prefer the lint results to appear right in your editor, there are some extra steps you can do. + +You would need to install an ESLint plugin for your editor first. Then, add a file called `.eslintrc` to the project root: + +```js +{ + "extends": "react-app" +} +``` + +Now your editor should report the linting warnings. + +Note that even if you edit your `.eslintrc` file further, these changes will **only affect the editor integration**. They won’t affect the terminal and in-browser lint output. This is because Create React App intentionally provides a minimal set of rules that find common mistakes. + +If you want to enforce a coding style for your project, consider using [Prettier](https://github.com/jlongster/prettier) instead of ESLint style rules. + +## Debugging in the Editor + +**This feature is currently only supported by [Visual Studio Code](https://code.visualstudio.com) and [WebStorm](https://www.jetbrains.com/webstorm/).** + +Visual Studio Code and WebStorm support debugging out of the box with Create React App. This enables you as a developer to write and debug your React code without leaving the editor, and most importantly it enables you to have a continuous development workflow, where context switching is minimal, as you don’t have to switch between tools. + +### Visual Studio Code + +You would need to have the latest version of [VS Code](https://code.visualstudio.com) and VS Code [Chrome Debugger Extension](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome) installed. + +Then add the block below to your `launch.json` file and put it inside the `.vscode` folder in your app’s root directory. + +```json +{ + "version": "0.2.0", + "configurations": [{ + "name": "Chrome", + "type": "chrome", + "request": "launch", + "url": "http://localhost:3000", + "webRoot": "${workspaceRoot}/src", + "sourceMapPathOverrides": { + "webpack:///src/*": "${webRoot}/*" + } + }] +} +``` +>Note: the URL may be different if you've made adjustments via the [HOST or PORT environment variables](#advanced-configuration). + +Start your app by running `npm start`, and start debugging in VS Code by pressing `F5` or by clicking the green debug icon. You can now write code, set breakpoints, make changes to the code, and debug your newly modified code—all from your editor. + +Having problems with VS Code Debugging? Please see their [troubleshooting guide](https://github.com/Microsoft/vscode-chrome-debug/blob/master/README.md#troubleshooting). + +### WebStorm + +You would need to have [WebStorm](https://www.jetbrains.com/webstorm/) and [JetBrains IDE Support](https://chrome.google.com/webstore/detail/jetbrains-ide-support/hmhgeddbohgjknpmjagkdomcpobmllji) Chrome extension installed. + +In the WebStorm menu `Run` select `Edit Configurations...`. Then click `+` and select `JavaScript Debug`. Paste `http://localhost:3000` into the URL field and save the configuration. + +>Note: the URL may be different if you've made adjustments via the [HOST or PORT environment variables](#advanced-configuration). + +Start your app by running `npm start`, then press `^D` on macOS or `F9` on Windows and Linux or click the green debug icon to start debugging in WebStorm. + +The same way you can debug your application in IntelliJ IDEA Ultimate, PhpStorm, PyCharm Pro, and RubyMine. + +## Formatting Code Automatically + +Prettier is an opinionated code formatter with support for JavaScript, CSS and JSON. With Prettier you can format the code you write automatically to ensure a code style within your project. See the [Prettier's GitHub page](https://github.com/prettier/prettier) for more information, and look at this [page to see it in action](https://prettier.github.io/prettier/). + +To format our code whenever we make a commit in git, we need to install the following dependencies: + +```sh +npm install --save husky lint-staged prettier +``` + +Alternatively you may use `yarn`: + +```sh +yarn add husky lint-staged prettier +``` + +* `husky` makes it easy to use githooks as if they are npm scripts. +* `lint-staged` allows us to run scripts on staged files in git. See this [blog post about lint-staged to learn more about it](https://medium.com/@okonetchnikov/make-linting-great-again-f3890e1ad6b8). +* `prettier` is the JavaScript formatter we will run before commits. + +Now we can make sure every file is formatted correctly by adding a few lines to the `package.json` in the project root. + +Add the following line to `scripts` section: + +```diff + "scripts": { ++ "precommit": "lint-staged", + "start": "react-scripts start", + "build": "react-scripts build", +``` + +Next we add a 'lint-staged' field to the `package.json`, for example: + +```diff + "dependencies": { + // ... + }, ++ "lint-staged": { ++ "src/**/*.{js,jsx,json,css}": [ ++ "prettier --single-quote --write", ++ "git add" ++ ] ++ }, + "scripts": { +``` + +Now, whenever you make a commit, Prettier will format the changed files automatically. You can also run `./node_modules/.bin/prettier --single-quote --write "src/**/*.{js,jsx}"` to format your entire project for the first time. + +Next you might want to integrate Prettier in your favorite editor. Read the section on [Editor Integration](https://github.com/prettier/prettier#editor-integration) on the Prettier GitHub page. + +## Changing the Page `<title>` + +You can find the source HTML file in the `public` folder of the generated project. You may edit the `<title>` tag in it to change the title from “React App” to anything else. + +Note that normally you wouldn’t edit files in the `public` folder very often. For example, [adding a stylesheet](#adding-a-stylesheet) is done without touching the HTML. + +If you need to dynamically update the page title based on the content, you can use the browser [`document.title`](https://developer.mozilla.org/en-US/docs/Web/API/Document/title) API. For more complex scenarios when you want to change the title from React components, you can use [React Helmet](https://github.com/nfl/react-helmet), a third party library. + +If you use a custom server for your app in production and want to modify the title before it gets sent to the browser, you can follow advice in [this section](#generating-dynamic-meta-tags-on-the-server). Alternatively, you can pre-build each page as a static HTML file which then loads the JavaScript bundle, which is covered [here](#pre-rendering-into-static-html-files). + +## Installing a Dependency + +The generated project includes React and ReactDOM as dependencies. It also includes a set of scripts used by Create React App as a development dependency. You may install other dependencies (for example, React Router) with `npm`: + +```sh +npm install --save react-router +``` + +Alternatively you may use `yarn`: + +```sh +yarn add react-router +``` + +This works for any library, not just `react-router`. + +## Importing a Component + +This project setup supports ES6 modules thanks to Babel.<br> +While you can still use `require()` and `module.exports`, we encourage you to use [`import` and `export`](http://exploringjs.com/es6/ch_modules.html) instead. + +For example: + +### `Button.js` + +```js +import React, { Component } from 'react'; + +class Button extends Component { + render() { + // ... + } +} + +export default Button; // Don’t forget to use export default! +``` + +### `DangerButton.js` + + +```js +import React, { Component } from 'react'; +import Button from './Button'; // Import a component from another file + +class DangerButton extends Component { + render() { + return <Button color="red" />; + } +} + +export default DangerButton; +``` + +Be aware of the [difference between default and named exports](http://stackoverflow.com/questions/36795819/react-native-es-6-when-should-i-use-curly-braces-for-import/36796281#36796281). It is a common source of mistakes. + +We suggest that you stick to using default imports and exports when a module only exports a single thing (for example, a component). That’s what you get when you use `export default Button` and `import Button from './Button'`. + +Named exports are useful for utility modules that export several functions. A module may have at most one default export and as many named exports as you like. + +Learn more about ES6 modules: + +* [When to use the curly braces?](http://stackoverflow.com/questions/36795819/react-native-es-6-when-should-i-use-curly-braces-for-import/36796281#36796281) +* [Exploring ES6: Modules](http://exploringjs.com/es6/ch_modules.html) +* [Understanding ES6: Modules](https://leanpub.com/understandinges6/read#leanpub-auto-encapsulating-code-with-modules) + +## Code Splitting + +Instead of downloading the entire app before users can use it, code splitting allows you to split your code into small chunks which you can then load on demand. + +This project setup supports code splitting via [dynamic `import()`](http://2ality.com/2017/01/import-operator.html#loading-code-on-demand). Its [proposal](https://github.com/tc39/proposal-dynamic-import) is in stage 3. The `import()` function-like form takes the module name as an argument and returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) which always resolves to the namespace object of the module. + +Here is an example: + +### `moduleA.js` + +```js +const moduleA = 'Hello'; + +export { moduleA }; +``` +### `App.js` + +```js +import React, { Component } from 'react'; + +class App extends Component { + handleClick = () => { + import('./moduleA') + .then(({ moduleA }) => { + // Use moduleA + }) + .catch(err => { + // Handle failure + }); + }; + + render() { + return ( + <div> + <button onClick={this.handleClick}>Load</button> + </div> + ); + } +} + +export default App; +``` + +This will make `moduleA.js` and all its unique dependencies as a separate chunk that only loads after the user clicks the 'Load' button. + +You can also use it with `async` / `await` syntax if you prefer it. + +### With React Router + +If you are using React Router check out [this tutorial](http://serverless-stack.com/chapters/code-splitting-in-create-react-app.html) on how to use code splitting with it. You can find the companion GitHub repository [here](https://github.com/AnomalyInnovations/serverless-stack-demo-client/tree/code-splitting-in-create-react-app). + +## Adding a Stylesheet + +This project setup uses [Webpack](https://webpack.js.org/) for handling all assets. Webpack offers a custom way of “extending” the concept of `import` beyond JavaScript. To express that a JavaScript file depends on a CSS file, you need to **import the CSS from the JavaScript file**: + +### `Button.css` + +```css +.Button { + padding: 20px; +} +``` + +### `Button.js` + +```js +import React, { Component } from 'react'; +import './Button.css'; // Tell Webpack that Button.js uses these styles + +class Button extends Component { + render() { + // You can use them as regular CSS styles + return <div className="Button" />; + } +} +``` + +**This is not required for React** but many people find this feature convenient. You can read about the benefits of this approach [here](https://medium.com/seek-ui-engineering/block-element-modifying-your-javascript-components-d7f99fcab52b). However you should be aware that this makes your code less portable to other build tools and environments than Webpack. + +In development, expressing dependencies this way allows your styles to be reloaded on the fly as you edit them. In production, all CSS files will be concatenated into a single minified `.css` file in the build output. + +If you are concerned about using Webpack-specific semantics, you can put all your CSS right into `src/index.css`. It would still be imported from `src/index.js`, but you could always remove that import if you later migrate to a different build tool. + +## Post-Processing CSS + +This project setup minifies your CSS and adds vendor prefixes to it automatically through [Autoprefixer](https://github.com/postcss/autoprefixer) so you don’t need to worry about it. + +For example, this: + +```css +.App { + display: flex; + flex-direction: row; + align-items: center; +} +``` + +becomes this: + +```css +.App { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: horizontal; + -webkit-box-direction: normal; + -ms-flex-direction: row; + flex-direction: row; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} +``` + +If you need to disable autoprefixing for some reason, [follow this section](https://github.com/postcss/autoprefixer#disabling). + +## Adding a CSS Preprocessor (Sass, Less etc.) + +Generally, we recommend that you don’t reuse the same CSS classes across different components. For example, instead of using a `.Button` CSS class in `<AcceptButton>` and `<RejectButton>` components, we recommend creating a `<Button>` component with its own `.Button` styles, that both `<AcceptButton>` and `<RejectButton>` can render (but [not inherit](https://facebook.github.io/react/docs/composition-vs-inheritance.html)). + +Following this rule often makes CSS preprocessors less useful, as features like mixins and nesting are replaced by component composition. You can, however, integrate a CSS preprocessor if you find it valuable. In this walkthrough, we will be using Sass, but you can also use Less, or another alternative. + +First, let’s install the command-line interface for Sass: + +```sh +npm install --save node-sass-chokidar +``` + +Alternatively you may use `yarn`: + +```sh +yarn add node-sass-chokidar +``` + +Then in `package.json`, add the following lines to `scripts`: + +```diff + "scripts": { ++ "build-css": "node-sass-chokidar src/ -o src/", ++ "watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive", + "start": "react-scripts start", + "build": "react-scripts build", + "test": "react-scripts test --env=jsdom", +``` + +>Note: To use a different preprocessor, replace `build-css` and `watch-css` commands according to your preprocessor’s documentation. + +Now you can rename `src/App.css` to `src/App.scss` and run `npm run watch-css`. The watcher will find every Sass file in `src` subdirectories, and create a corresponding CSS file next to it, in our case overwriting `src/App.css`. Since `src/App.js` still imports `src/App.css`, the styles become a part of your application. You can now edit `src/App.scss`, and `src/App.css` will be regenerated. + +To share variables between Sass files, you can use Sass imports. For example, `src/App.scss` and other component style files could include `@import "./shared.scss";` with variable definitions. + +To enable importing files without using relative paths, you can add the `--include-path` option to the command in `package.json`. + +``` +"build-css": "node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/", +"watch-css": "npm run build-css && node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/ --watch --recursive", +``` + +This will allow you to do imports like + +```scss +@import 'styles/_colors.scss'; // assuming a styles directory under src/ +@import 'nprogress/nprogress'; // importing a css file from the nprogress node module +``` + +At this point you might want to remove all CSS files from the source control, and add `src/**/*.css` to your `.gitignore` file. It is generally a good practice to keep the build products outside of the source control. + +As a final step, you may find it convenient to run `watch-css` automatically with `npm start`, and run `build-css` as a part of `npm run build`. You can use the `&&` operator to execute two scripts sequentially. However, there is no cross-platform way to run two scripts in parallel, so we will install a package for this: + +```sh +npm install --save npm-run-all +``` + +Alternatively you may use `yarn`: + +```sh +yarn add npm-run-all +``` + +Then we can change `start` and `build` scripts to include the CSS preprocessor commands: + +```diff + "scripts": { + "build-css": "node-sass-chokidar src/ -o src/", + "watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive", +- "start": "react-scripts start", +- "build": "react-scripts build", ++ "start-js": "react-scripts start", ++ "start": "npm-run-all -p watch-css start-js", ++ "build-js": "react-scripts build", ++ "build": "npm-run-all build-css build-js", + "test": "react-scripts test --env=jsdom", + "eject": "react-scripts eject" + } +``` + +Now running `npm start` and `npm run build` also builds Sass files. + +**Why `node-sass-chokidar`?** + +`node-sass` has been reported as having the following issues: + +- `node-sass --watch` has been reported to have *performance issues* in certain conditions when used in a virtual machine or with docker. + +- Infinite styles compiling [#1939](https://github.com/facebookincubator/create-react-app/issues/1939) + +- `node-sass` has been reported as having issues with detecting new files in a directory [#1891](https://github.com/sass/node-sass/issues/1891) + + `node-sass-chokidar` is used here as it addresses these issues. + +## Adding Images, Fonts, and Files + +With Webpack, using static assets like images and fonts works similarly to CSS. + +You can **`import` a file right in a JavaScript module**. This tells Webpack to include that file in the bundle. Unlike CSS imports, importing a file gives you a string value. This value is the final path you can reference in your code, e.g. as the `src` attribute of an image or the `href` of a link to a PDF. + +To reduce the number of requests to the server, importing images that are less than 10,000 bytes returns a [data URI](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) instead of a path. This applies to the following file extensions: bmp, gif, jpg, jpeg, and png. SVG files are excluded due to [#1153](https://github.com/facebookincubator/create-react-app/issues/1153). + +Here is an example: + +```js +import React from 'react'; +import logo from './logo.png'; // Tell Webpack this JS file uses this image + +console.log(logo); // /logo.84287d09.png + +function Header() { + // Import result is the URL of your image + return <img src={logo} alt="Logo" />; +} + +export default Header; +``` + +This ensures that when the project is built, Webpack will correctly move the images into the build folder, and provide us with correct paths. + +This works in CSS too: + +```css +.Logo { + background-image: url(./logo.png); +} +``` + +Webpack finds all relative module references in CSS (they start with `./`) and replaces them with the final paths from the compiled bundle. If you make a typo or accidentally delete an important file, you will see a compilation error, just like when you import a non-existent JavaScript module. The final filenames in the compiled bundle are generated by Webpack from content hashes. If the file content changes in the future, Webpack will give it a different name in production so you don’t need to worry about long-term caching of assets. + +Please be advised that this is also a custom feature of Webpack. + +**It is not required for React** but many people enjoy it (and React Native uses a similar mechanism for images).<br> +An alternative way of handling static assets is described in the next section. + +## Using the `public` Folder + +>Note: this feature is available with `react-scripts@0.5.0` and higher. + +### Changing the HTML + +The `public` folder contains the HTML file so you can tweak it, for example, to [set the page title](#changing-the-page-title). +The `<script>` tag with the compiled code will be added to it automatically during the build process. + +### Adding Assets Outside of the Module System + +You can also add other assets to the `public` folder. + +Note that we normally encourage you to `import` assets in JavaScript files instead. +For example, see the sections on [adding a stylesheet](#adding-a-stylesheet) and [adding images and fonts](#adding-images-fonts-and-files). +This mechanism provides a number of benefits: + +* Scripts and stylesheets get minified and bundled together to avoid extra network requests. +* Missing files cause compilation errors instead of 404 errors for your users. +* Result filenames include content hashes so you don’t need to worry about browsers caching their old versions. + +However there is an **escape hatch** that you can use to add an asset outside of the module system. + +If you put a file into the `public` folder, it will **not** be processed by Webpack. Instead it will be copied into the build folder untouched. To reference assets in the `public` folder, you need to use a special variable called `PUBLIC_URL`. + +Inside `index.html`, you can use it like this: + +```html +<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"> +``` + +Only files inside the `public` folder will be accessible by `%PUBLIC_URL%` prefix. If you need to use a file from `src` or `node_modules`, you’ll have to copy it there to explicitly specify your intention to make this file a part of the build. + +When you run `npm run build`, Create React App will substitute `%PUBLIC_URL%` with a correct absolute path so your project works even if you use client-side routing or host it at a non-root URL. + +In JavaScript code, you can use `process.env.PUBLIC_URL` for similar purposes: + +```js +render() { + // Note: this is an escape hatch and should be used sparingly! + // Normally we recommend using `import` for getting asset URLs + // as described in “Adding Images and Fonts” above this section. + return <img src={process.env.PUBLIC_URL + '/img/logo.png'} />; +} +``` + +Keep in mind the downsides of this approach: + +* None of the files in `public` folder get post-processed or minified. +* Missing files will not be called at compilation time, and will cause 404 errors for your users. +* Result filenames won’t include content hashes so you’ll need to add query arguments or rename them every time they change. + +### When to Use the `public` Folder + +Normally we recommend importing [stylesheets](#adding-a-stylesheet), [images, and fonts](#adding-images-fonts-and-files) from JavaScript. +The `public` folder is useful as a workaround for a number of less common cases: + +* You need a file with a specific name in the build output, such as [`manifest.webmanifest`](https://developer.mozilla.org/en-US/docs/Web/Manifest). +* You have thousands of images and need to dynamically reference their paths. +* You want to include a small script like [`pace.js`](http://github.hubspot.com/pace/docs/welcome/) outside of the bundled code. +* Some library may be incompatible with Webpack and you have no other option but to include it as a `<script>` tag. + +Note that if you add a `<script>` that declares global variables, you also need to read the next section on using them. + +## Using Global Variables + +When you include a script in the HTML file that defines global variables and try to use one of these variables in the code, the linter will complain because it cannot see the definition of the variable. + +You can avoid this by reading the global variable explicitly from the `window` object, for example: + +```js +const $ = window.$; +``` + +This makes it obvious you are using a global variable intentionally rather than because of a typo. + +Alternatively, you can force the linter to ignore any line by adding `// eslint-disable-line` after it. + +## Adding Bootstrap + +You don’t have to use [Reactstrap](https://reactstrap.github.io/) together with React but it is a popular library for integrating Bootstrap with React apps. If you need it, you can integrate it with Create React App by following these steps: + +Install Reactstrap and Bootstrap from npm. React Bootstrap does not include Bootstrap CSS so this needs to be installed as well: + +```sh +npm install --save reactstrap bootstrap@4 +``` + +Alternatively you may use `yarn`: + +```sh +yarn add reactstrap bootstrap@4 +``` + +Import Bootstrap CSS and optionally Bootstrap theme CSS in the beginning of your ```src/index.js``` file: + +```js +import 'bootstrap/dist/css/bootstrap.css'; +// Put any other imports below so that CSS from your +// components takes precedence over default styles. +``` + +Import required React Bootstrap components within ```src/App.js``` file or your custom component files: + +```js +import { Navbar, Button } from 'reactstrap'; +``` + +Now you are ready to use the imported React Bootstrap components within your component hierarchy defined in the render method. Here is an example [`App.js`](https://gist.githubusercontent.com/gaearon/85d8c067f6af1e56277c82d19fd4da7b/raw/6158dd991b67284e9fc8d70b9d973efe87659d72/App.js) redone using React Bootstrap. + +### Using a Custom Theme + +Sometimes you might need to tweak the visual styles of Bootstrap (or equivalent package).<br> +We suggest the following approach: + +* Create a new package that depends on the package you wish to customize, e.g. Bootstrap. +* Add the necessary build steps to tweak the theme, and publish your package on npm. +* Install your own theme npm package as a dependency of your app. + +Here is an example of adding a [customized Bootstrap](https://medium.com/@tacomanator/customizing-create-react-app-aa9ffb88165) that follows these steps. + +## Adding Flow + +Flow is a static type checker that helps you write code with fewer bugs. Check out this [introduction to using static types in JavaScript](https://medium.com/@preethikasireddy/why-use-static-types-in-javascript-part-1-8382da1e0adb) if you are new to this concept. + +Recent versions of [Flow](http://flowtype.org/) work with Create React App projects out of the box. + +To add Flow to a Create React App project, follow these steps: + +1. Run `npm install --save flow-bin` (or `yarn add flow-bin`). +2. Add `"flow": "flow"` to the `scripts` section of your `package.json`. +3. Run `npm run flow init` (or `yarn flow init`) to create a [`.flowconfig` file](https://flowtype.org/docs/advanced-configuration.html) in the root directory. +4. Add `// @flow` to any files you want to type check (for example, to `src/App.js`). + +Now you can run `npm run flow` (or `yarn flow`) to check the files for type errors. +You can optionally use an IDE like [Nuclide](https://nuclide.io/docs/languages/flow/) for a better integrated experience. +In the future we plan to integrate it into Create React App even more closely. + +To learn more about Flow, check out [its documentation](https://flowtype.org/). + +## Adding Custom Environment Variables + +>Note: this feature is available with `react-scripts@0.2.3` and higher. + +Your project can consume variables declared in your environment as if they were declared locally in your JS files. By +default you will have `NODE_ENV` defined for you, and any other environment variables starting with +`REACT_APP_`. + +**The environment variables are embedded during the build time**. Since Create React App produces a static HTML/CSS/JS bundle, it can’t possibly read them at runtime. To read them at runtime, you would need to load HTML into memory on the server and replace placeholders in runtime, just like [described here](#injecting-data-from-the-server-into-the-page). Alternatively you can rebuild the app on the server anytime you change them. + +>Note: You must create custom environment variables beginning with `REACT_APP_`. Any other variables except `NODE_ENV` will be ignored to avoid accidentally [exposing a private key on the machine that could have the same name](https://github.com/facebookincubator/create-react-app/issues/865#issuecomment-252199527). Changing any environment variables will require you to restart the development server if it is running. + +These environment variables will be defined for you on `process.env`. For example, having an environment +variable named `REACT_APP_SECRET_CODE` will be exposed in your JS as `process.env.REACT_APP_SECRET_CODE`. + +There is also a special built-in environment variable called `NODE_ENV`. You can read it from `process.env.NODE_ENV`. When you run `npm start`, it is always equal to `'development'`, when you run `npm test` it is always equal to `'test'`, and when you run `npm run build` to make a production bundle, it is always equal to `'production'`. **You cannot override `NODE_ENV` manually.** This prevents developers from accidentally deploying a slow development build to production. + +These environment variables can be useful for displaying information conditionally based on where the project is +deployed or consuming sensitive data that lives outside of version control. + +First, you need to have environment variables defined. For example, let’s say you wanted to consume a secret defined +in the environment inside a `<form>`: + +```jsx +render() { + return ( + <div> + <small>You are running this application in <b>{process.env.NODE_ENV}</b> mode.</small> + <form> + <input type="hidden" defaultValue={process.env.REACT_APP_SECRET_CODE} /> + </form> + </div> + ); +} +``` + +During the build, `process.env.REACT_APP_SECRET_CODE` will be replaced with the current value of the `REACT_APP_SECRET_CODE` environment variable. Remember that the `NODE_ENV` variable will be set for you automatically. + +When you load the app in the browser and inspect the `<input>`, you will see its value set to `abcdef`, and the bold text will show the environment provided when using `npm start`: + +```html +<div> + <small>You are running this application in <b>development</b> mode.</small> + <form> + <input type="hidden" value="abcdef" /> + </form> +</div> +``` + +The above form is looking for a variable called `REACT_APP_SECRET_CODE` from the environment. In order to consume this +value, we need to have it defined in the environment. This can be done using two ways: either in your shell or in +a `.env` file. Both of these ways are described in the next few sections. + +Having access to the `NODE_ENV` is also useful for performing actions conditionally: + +```js +if (process.env.NODE_ENV !== 'production') { + analytics.disable(); +} +``` + +When you compile the app with `npm run build`, the minification step will strip out this condition, and the resulting bundle will be smaller. + +### Referencing Environment Variables in the HTML + +>Note: this feature is available with `react-scripts@0.9.0` and higher. + +You can also access the environment variables starting with `REACT_APP_` in the `public/index.html`. For example: + +```html +<title>%REACT_APP_WEBSITE_NAME% +``` + +Note that the caveats from the above section apply: + +* Apart from a few built-in variables (`NODE_ENV` and `PUBLIC_URL`), variable names must start with `REACT_APP_` to work. +* The environment variables are injected at build time. If you need to inject them at runtime, [follow this approach instead](#generating-dynamic-meta-tags-on-the-server). + +### Adding Temporary Environment Variables In Your Shell + +Defining environment variables can vary between OSes. It’s also important to know that this manner is temporary for the +life of the shell session. + +#### Windows (cmd.exe) + +```cmd +set REACT_APP_SECRET_CODE=abcdef&&npm start +``` + +(Note: the lack of whitespace is intentional.) + +#### Linux, macOS (Bash) + +```bash +REACT_APP_SECRET_CODE=abcdef npm start +``` + +### Adding Development Environment Variables In `.env` + +>Note: this feature is available with `react-scripts@0.5.0` and higher. + +To define permanent environment variables, create a file called `.env` in the root of your project: + +``` +REACT_APP_SECRET_CODE=abcdef +``` + +`.env` files **should be** checked into source control (with the exclusion of `.env*.local`). + +#### What other `.env` files can be used? + +>Note: this feature is **available with `react-scripts@1.0.0` and higher**. + +* `.env`: Default. +* `.env.local`: Local overrides. **This file is loaded for all environments except test.** +* `.env.development`, `.env.test`, `.env.production`: Environment-specific settings. +* `.env.development.local`, `.env.test.local`, `.env.production.local`: Local overrides of environment-specific settings. + +Files on the left have more priority than files on the right: + +* `npm start`: `.env.development.local`, `.env.development`, `.env.local`, `.env` +* `npm run build`: `.env.production.local`, `.env.production`, `.env.local`, `.env` +* `npm test`: `.env.test.local`, `.env.test`, `.env` (note `.env.local` is missing) + +These variables will act as the defaults if the machine does not explicitly set them.
+Please refer to the [dotenv documentation](https://github.com/motdotla/dotenv) for more details. + +>Note: If you are defining environment variables for development, your CI and/or hosting platform will most likely need +these defined as well. Consult their documentation how to do this. For example, see the documentation for [Travis CI](https://docs.travis-ci.com/user/environment-variables/) or [Heroku](https://devcenter.heroku.com/articles/config-vars). + +## Can I Use Decorators? + +Many popular libraries use [decorators](https://medium.com/google-developers/exploring-es7-decorators-76ecb65fb841) in their documentation.
+Create React App doesn’t support decorator syntax at the moment because: + +* It is an experimental proposal and is subject to change. +* The current specification version is not officially supported by Babel. +* If the specification changes, we won’t be able to write a codemod because we don’t use them internally at Facebook. + +However in many cases you can rewrite decorator-based code without decorators just as fine.
+Please refer to these two threads for reference: + +* [#214](https://github.com/facebookincubator/create-react-app/issues/214) +* [#411](https://github.com/facebookincubator/create-react-app/issues/411) + +Create React App will add decorator support when the specification advances to a stable stage. + +## Integrating with an API Backend + +These tutorials will help you to integrate your app with an API backend running on another port, +using `fetch()` to access it. + +### Node +Check out [this tutorial](https://www.fullstackreact.com/articles/using-create-react-app-with-a-server/). +You can find the companion GitHub repository [here](https://github.com/fullstackreact/food-lookup-demo). + +### Ruby on Rails + +Check out [this tutorial](https://www.fullstackreact.com/articles/how-to-get-create-react-app-to-work-with-your-rails-api/). +You can find the companion GitHub repository [here](https://github.com/fullstackreact/food-lookup-demo-rails). + +## Proxying API Requests in Development + +>Note: this feature is available with `react-scripts@0.2.3` and higher. + +People often serve the front-end React app from the same host and port as their backend implementation.
+For example, a production setup might look like this after the app is deployed: + +``` +/ - static server returns index.html with React app +/todos - static server returns index.html with React app +/api/todos - server handles any /api/* requests using the backend implementation +``` + +Such setup is **not** required. However, if you **do** have a setup like this, it is convenient to write requests like `fetch('/api/todos')` without worrying about redirecting them to another host or port during development. + +To tell the development server to proxy any unknown requests to your API server in development, add a `proxy` field to your `package.json`, for example: + +```js + "proxy": "http://localhost:4000", +``` + +This way, when you `fetch('/api/todos')` in development, the development server will recognize that it’s not a static asset, and will proxy your request to `http://localhost:4000/api/todos` as a fallback. The development server will **only** attempt to send requests without `text/html` in its `Accept` header to the proxy. + +Conveniently, this avoids [CORS issues](http://stackoverflow.com/questions/21854516/understanding-ajax-cors-and-security-considerations) and error messages like this in development: + +``` +Fetch API cannot load http://localhost:4000/api/todos. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. +``` + +Keep in mind that `proxy` only has effect in development (with `npm start`), and it is up to you to ensure that URLs like `/api/todos` point to the right thing in production. You don’t have to use the `/api` prefix. Any unrecognized request without a `text/html` accept header will be redirected to the specified `proxy`. + +The `proxy` option supports HTTP, HTTPS and WebSocket connections.
+If the `proxy` option is **not** flexible enough for you, alternatively you can: + +* [Configure the proxy yourself](#configuring-the-proxy-manually) +* Enable CORS on your server ([here’s how to do it for Express](http://enable-cors.org/server_expressjs.html)). +* Use [environment variables](#adding-custom-environment-variables) to inject the right server host and port into your app. + +### "Invalid Host Header" Errors After Configuring Proxy + +When you enable the `proxy` option, you opt into a more strict set of host checks. This is necessary because leaving the backend open to remote hosts makes your computer vulnerable to DNS rebinding attacks. The issue is explained in [this article](https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a) and [this issue](https://github.com/webpack/webpack-dev-server/issues/887). + +This shouldn’t affect you when developing on `localhost`, but if you develop remotely like [described here](https://github.com/facebookincubator/create-react-app/issues/2271), you will see this error in the browser after enabling the `proxy` option: + +>Invalid Host header + +To work around it, you can specify your public development host in a file called `.env.development` in the root of your project: + +``` +HOST=mypublicdevhost.com +``` + +If you restart the development server now and load the app from the specified host, it should work. + +If you are still having issues or if you’re using a more exotic environment like a cloud editor, you can bypass the host check completely by adding a line to `.env.development.local`. **Note that this is dangerous and exposes your machine to remote code execution from malicious websites:** + +``` +# NOTE: THIS IS DANGEROUS! +# It exposes your machine to attacks from the websites you visit. +DANGEROUSLY_DISABLE_HOST_CHECK=true +``` + +We don’t recommend this approach. + +### Configuring the Proxy Manually + +>Note: this feature is available with `react-scripts@1.0.0` and higher. + +If the `proxy` option is **not** flexible enough for you, you can specify an object in the following form (in `package.json`).
+You may also specify any configuration value [`http-proxy-middleware`](https://github.com/chimurai/http-proxy-middleware#options) or [`http-proxy`](https://github.com/nodejitsu/node-http-proxy#options) supports. +```js +{ + // ... + "proxy": { + "/api": { + "target": "", + "ws": true + // ... + } + } + // ... +} +``` + +All requests matching this path will be proxies, no exceptions. This includes requests for `text/html`, which the standard `proxy` option does not proxy. + +If you need to specify multiple proxies, you may do so by specifying additional entries. +Matches are regular expressions, so that you can use a regexp to match multiple paths. +```js +{ + // ... + "proxy": { + // Matches any request starting with /api + "/api": { + "target": "", + "ws": true + // ... + }, + // Matches any request starting with /foo + "/foo": { + "target": "", + "ssl": true, + "pathRewrite": { + "^/foo": "/foo/beta" + } + // ... + }, + // Matches /bar/abc.html but not /bar/sub/def.html + "/bar/[^/]*[.]html": { + "target": "", + // ... + }, + // Matches /baz/abc.html and /baz/sub/def.html + "/baz/.*/.*[.]html": { + "target": "" + // ... + } + } + // ... +} +``` + +### Configuring a WebSocket Proxy + +When setting up a WebSocket proxy, there are a some extra considerations to be aware of. + +If you’re using a WebSocket engine like [Socket.io](https://socket.io/), you must have a Socket.io server running that you can use as the proxy target. Socket.io will not work with a standard WebSocket server. Specifically, don't expect Socket.io to work with [the websocket.org echo test](http://websocket.org/echo.html). + +There’s some good documentation available for [setting up a Socket.io server](https://socket.io/docs/). + +Standard WebSockets **will** work with a standard WebSocket server as well as the websocket.org echo test. You can use libraries like [ws](https://github.com/websockets/ws) for the server, with [native WebSockets in the browser](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket). + +Either way, you can proxy WebSocket requests manually in `package.json`: + +```js +{ + // ... + "proxy": { + "/socket": { + // Your compatible WebSocket server + "target": "ws://", + // Tell http-proxy-middleware that this is a WebSocket proxy. + // Also allows you to proxy WebSocket requests without an additional HTTP request + // https://github.com/chimurai/http-proxy-middleware#external-websocket-upgrade + "ws": true + // ... + } + } + // ... +} +``` + +## Using HTTPS in Development + +>Note: this feature is available with `react-scripts@0.4.0` and higher. + +You may require the dev server to serve pages over HTTPS. One particular case where this could be useful is when using [the "proxy" feature](#proxying-api-requests-in-development) to proxy requests to an API server when that API server is itself serving HTTPS. + +To do this, set the `HTTPS` environment variable to `true`, then start the dev server as usual with `npm start`: + +#### Windows (cmd.exe) + +```cmd +set HTTPS=true&&npm start +``` + +(Note: the lack of whitespace is intentional.) + +#### Linux, macOS (Bash) + +```bash +HTTPS=true npm start +``` + +Note that the server will use a self-signed certificate, so your web browser will almost definitely display a warning upon accessing the page. + +## Generating Dynamic `` Tags on the Server + +Since Create React App doesn’t support server rendering, you might be wondering how to make `` tags dynamic and reflect the current URL. To solve this, we recommend to add placeholders into the HTML, like this: + +```html + + + + + +``` + +Then, on the server, regardless of the backend you use, you can read `index.html` into memory and replace `__OG_TITLE__`, `__OG_DESCRIPTION__`, and any other placeholders with values depending on the current URL. Just make sure to sanitize and escape the interpolated values so that they are safe to embed into HTML! + +If you use a Node server, you can even share the route matching logic between the client and the server. However duplicating it also works fine in simple cases. + +## Pre-Rendering into Static HTML Files + +If you’re hosting your `build` with a static hosting provider you can use [react-snapshot](https://www.npmjs.com/package/react-snapshot) or [react-snap](https://github.com/stereobooster/react-snap) to generate HTML pages for each route, or relative link, in your application. These pages will then seamlessly become active, or “hydrated”, when the JavaScript bundle has loaded. + +There are also opportunities to use this outside of static hosting, to take the pressure off the server when generating and caching routes. + +The primary benefit of pre-rendering is that you get the core content of each page _with_ the HTML payload—regardless of whether or not your JavaScript bundle successfully downloads. It also increases the likelihood that each route of your application will be picked up by search engines. + +You can read more about [zero-configuration pre-rendering (also called snapshotting) here](https://medium.com/superhighfives/an-almost-static-stack-6df0a2791319). + +## Injecting Data from the Server into the Page + +Similarly to the previous section, you can leave some placeholders in the HTML that inject global variables, for example: + +```js + + + + +``` + +Then, on the server, you can replace `__SERVER_DATA__` with a JSON of real data right before sending the response. The client code can then read `window.SERVER_DATA` to use it. **Make sure to [sanitize the JSON before sending it to the client](https://medium.com/node-security/the-most-common-xss-vulnerability-in-react-js-applications-2bdffbcc1fa0) as it makes your app vulnerable to XSS attacks.** + +## Running Tests + +>Note: this feature is available with `react-scripts@0.3.0` and higher.
+>[Read the migration guide to learn how to enable it in older projects!](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md#migrating-from-023-to-030) + +Create React App uses [Jest](https://facebook.github.io/jest/) as its test runner. To prepare for this integration, we did a [major revamp](https://facebook.github.io/jest/blog/2016/09/01/jest-15.html) of Jest so if you heard bad things about it years ago, give it another try. + +Jest is a Node-based runner. This means that the tests always run in a Node environment and not in a real browser. This lets us enable fast iteration speed and prevent flakiness. + +While Jest provides browser globals such as `window` thanks to [jsdom](https://github.com/tmpvar/jsdom), they are only approximations of the real browser behavior. Jest is intended to be used for unit tests of your logic and your components rather than the DOM quirks. + +We recommend that you use a separate tool for browser end-to-end tests if you need them. They are beyond the scope of Create React App. + +### Filename Conventions + +Jest will look for test files with any of the following popular naming conventions: + +* Files with `.js` suffix in `__tests__` folders. +* Files with `.test.js` suffix. +* Files with `.spec.js` suffix. + +The `.test.js` / `.spec.js` files (or the `__tests__` folders) can be located at any depth under the `src` top level folder. + +We recommend to put the test files (or `__tests__` folders) next to the code they are testing so that relative imports appear shorter. For example, if `App.test.js` and `App.js` are in the same folder, the test just needs to `import App from './App'` instead of a long relative path. Colocation also helps find tests more quickly in larger projects. + +### Command Line Interface + +When you run `npm test`, Jest will launch in the watch mode. Every time you save a file, it will re-run the tests, just like `npm start` recompiles the code. + +The watcher includes an interactive command-line interface with the ability to run all tests, or focus on a search pattern. It is designed this way so that you can keep it open and enjoy fast re-runs. You can learn the commands from the “Watch Usage” note that the watcher prints after every run: + +![Jest watch mode](http://facebook.github.io/jest/img/blog/15-watch.gif) + +### Version Control Integration + +By default, when you run `npm test`, Jest will only run the tests related to files changed since the last commit. This is an optimization designed to make your tests run fast regardless of how many tests you have. However it assumes that you don’t often commit the code that doesn’t pass the tests. + +Jest will always explicitly mention that it only ran tests related to the files changed since the last commit. You can also press `a` in the watch mode to force Jest to run all tests. + +Jest will always run all tests on a [continuous integration](#continuous-integration) server or if the project is not inside a Git or Mercurial repository. + +### Writing Tests + +To create tests, add `it()` (or `test()`) blocks with the name of the test and its code. You may optionally wrap them in `describe()` blocks for logical grouping but this is neither required nor recommended. + +Jest provides a built-in `expect()` global function for making assertions. A basic test could look like this: + +```js +import sum from './sum'; + +it('sums numbers', () => { + expect(sum(1, 2)).toEqual(3); + expect(sum(2, 2)).toEqual(4); +}); +``` + +All `expect()` matchers supported by Jest are [extensively documented here](https://facebook.github.io/jest/docs/en/expect.html#content).
+You can also use [`jest.fn()` and `expect(fn).toBeCalled()`](https://facebook.github.io/jest/docs/en/expect.html#tohavebeencalled) to create “spies” or mock functions. + +### Testing Components + +There is a broad spectrum of component testing techniques. They range from a “smoke test” verifying that a component renders without throwing, to shallow rendering and testing some of the output, to full rendering and testing component lifecycle and state changes. + +Different projects choose different testing tradeoffs based on how often components change, and how much logic they contain. If you haven’t decided on a testing strategy yet, we recommend that you start with creating simple smoke tests for your components: + +```js +import React from 'react'; +import ReactDOM from 'react-dom'; +import App from './App'; + +it('renders without crashing', () => { + const div = document.createElement('div'); + ReactDOM.render(, div); +}); +``` + +This test mounts a component and makes sure that it didn’t throw during rendering. Tests like this provide a lot value with very little effort so they are great as a starting point, and this is the test you will find in `src/App.test.js`. + +When you encounter bugs caused by changing components, you will gain a deeper insight into which parts of them are worth testing in your application. This might be a good time to introduce more specific tests asserting specific expected output or behavior. + +If you’d like to test components in isolation from the child components they render, we recommend using [`shallow()` rendering API](http://airbnb.io/enzyme/docs/api/shallow.html) from [Enzyme](http://airbnb.io/enzyme/). To install it, run: + +```sh +npm install --save enzyme enzyme-adapter-react-16 react-test-renderer +``` + +Alternatively you may use `yarn`: + +```sh +yarn add enzyme enzyme-adapter-react-16 react-test-renderer +``` + +As of Enzyme 3, you will need to install Enzyme along with an Adapter corresponding to the version of React you are using. (The examples above use the adapter for React 16.) + +The adapter will also need to be configured in your [global setup file](#initializing-test-environment): + +#### `src/setupTests.js` +```js +import { configure } from 'enzyme'; +import Adapter from 'enzyme-adapter-react-16'; + +configure({ adapter: new Adapter() }); +``` + +Now you can write a smoke test with it: + +```js +import React from 'react'; +import { shallow } from 'enzyme'; +import App from './App'; + +it('renders without crashing', () => { + shallow(); +}); +``` + +Unlike the previous smoke test using `ReactDOM.render()`, this test only renders `` and doesn’t go deeper. For example, even if `` itself renders a ` + + ); + } +} diff --git a/Project1/ClientApp/src/components/FetchData.js b/Project1/ClientApp/src/components/FetchData.js new file mode 100644 index 000000000..25d920654 --- /dev/null +++ b/Project1/ClientApp/src/components/FetchData.js @@ -0,0 +1,59 @@ +import React, { Component } from 'react'; + +export class FetchData extends Component { + static displayName = FetchData.name; + + constructor(props) { + super(props); + this.state = { forecasts: [], loading: true }; + } + + componentDidMount() { + this.populateWeatherData(); + } + + static renderForecastsTable(forecasts) { + return ( + + + + + + + + + + + {forecasts.map(forecast => + + + + + + + )} + +
DateTemp. (C)Temp. (F)Summary
{forecast.date}{forecast.temperatureC}{forecast.temperatureF}{forecast.summary}
+ ); + } + + render() { + let contents = this.state.loading + ?

Loading...

+ : FetchData.renderForecastsTable(this.state.forecasts); + + return ( +
+

Weather forecast

+

This component demonstrates fetching data from the server.

+ {contents} +
+ ); + } + + async populateWeatherData() { + const response = await fetch('weatherforecast'); + const data = await response.json(); + this.setState({ forecasts: data, loading: false }); + } +} diff --git a/Project1/ClientApp/src/components/Home.js b/Project1/ClientApp/src/components/Home.js new file mode 100644 index 000000000..7f6b28e71 --- /dev/null +++ b/Project1/ClientApp/src/components/Home.js @@ -0,0 +1,26 @@ +import React, { Component } from 'react'; + +export class Home extends Component { + static displayName = Home.name; + + render () { + return ( +
+

Hello, world!

+

Welcome to your new single-page application, built with:

+
+

To help you get started, we have also set up:

+
    +
  • Client-side navigation. For example, click Counter then Back to return here.
  • +
  • Development server integration. In development mode, the development server from create-react-app runs in the background automatically, so your client-side resources are dynamically built on demand and the page refreshes when you modify any file.
  • +
  • Efficient production builds. In production mode, development-time features are disabled, and your dotnet publish configuration produces minified, efficiently bundled JavaScript files.
  • +
+

The ClientApp subdirectory is a standard React application based on the create-react-app template. If you open a command prompt in that directory, you can run npm commands such as npm test or npm install.

+
+ ); + } +} diff --git a/Project1/ClientApp/src/components/Layout.js b/Project1/ClientApp/src/components/Layout.js new file mode 100644 index 000000000..6d4e876dc --- /dev/null +++ b/Project1/ClientApp/src/components/Layout.js @@ -0,0 +1,18 @@ +import React, { Component } from 'react'; +import { Container } from 'reactstrap'; +import { NavMenu } from './NavMenu'; + +export class Layout extends Component { + static displayName = Layout.name; + + render () { + return ( +
+ + + {this.props.children} + +
+ ); + } +} diff --git a/Project1/ClientApp/src/components/NavMenu.css b/Project1/ClientApp/src/components/NavMenu.css new file mode 100644 index 000000000..9214b0eae --- /dev/null +++ b/Project1/ClientApp/src/components/NavMenu.css @@ -0,0 +1,18 @@ +a.navbar-brand { + white-space: normal; + text-align: center; + word-break: break-all; +} + +html { + font-size: 14px; +} +@media (min-width: 768px) { + html { + font-size: 16px; + } +} + +.box-shadow { + box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); +} diff --git a/Project1/ClientApp/src/components/NavMenu.js b/Project1/ClientApp/src/components/NavMenu.js new file mode 100644 index 000000000..17af78a1c --- /dev/null +++ b/Project1/ClientApp/src/components/NavMenu.js @@ -0,0 +1,49 @@ +import React, { Component } from 'react'; +import { Collapse, Container, Navbar, NavbarBrand, NavbarToggler, NavItem, NavLink } from 'reactstrap'; +import { Link } from 'react-router-dom'; +import './NavMenu.css'; + +export class NavMenu extends Component { + static displayName = NavMenu.name; + + constructor (props) { + super(props); + + this.toggleNavbar = this.toggleNavbar.bind(this); + this.state = { + collapsed: true + }; + } + + toggleNavbar () { + this.setState({ + collapsed: !this.state.collapsed + }); + } + + render () { + return ( +
+ + + Project1 + + +
    + + Home + + + Counter + + + Fetch data + +
+
+
+
+
+ ); + } +} diff --git a/Project1/ClientApp/src/custom.css b/Project1/ClientApp/src/custom.css new file mode 100644 index 000000000..5fdfd061c --- /dev/null +++ b/Project1/ClientApp/src/custom.css @@ -0,0 +1,14 @@ +/* Provide sufficient contrast against white background */ +a { + color: #0366d6; +} + +code { + color: #E01A76; +} + +.btn-primary { + color: #fff; + background-color: #1b6ec2; + border-color: #1861ac; +} diff --git a/Project1/ClientApp/src/index.js b/Project1/ClientApp/src/index.js new file mode 100644 index 000000000..fe0154d09 --- /dev/null +++ b/Project1/ClientApp/src/index.js @@ -0,0 +1,18 @@ +import 'bootstrap/dist/css/bootstrap.css'; +import React from 'react'; +import ReactDOM from 'react-dom'; +import { BrowserRouter } from 'react-router-dom'; +import App from './App'; +import registerServiceWorker from './registerServiceWorker'; + +const baseUrl = document.getElementsByTagName('base')[0].getAttribute('href'); +const rootElement = document.getElementById('root'); + +ReactDOM.render( + + + , + rootElement); + +registerServiceWorker(); + diff --git a/Project1/ClientApp/src/registerServiceWorker.js b/Project1/ClientApp/src/registerServiceWorker.js new file mode 100644 index 000000000..10b0bafb3 --- /dev/null +++ b/Project1/ClientApp/src/registerServiceWorker.js @@ -0,0 +1,108 @@ +// In production, we register a service worker to serve assets from local cache. + +// This lets the app load faster on subsequent visits in production, and gives +// it offline capabilities. However, it also means that developers (and users) +// will only see deployed updates on the "N+1" visit to a page, since previously +// cached resources are updated in the background. + +// To learn more about the benefits of this model, read https://goo.gl/KwvDNy. +// This link also includes instructions on opting out of this behavior. + +const isLocalhost = Boolean( + window.location.hostname === 'localhost' || + // [::1] is the IPv6 localhost address. + window.location.hostname === '[::1]' || + // 127.0.0.1/8 is considered localhost for IPv4. + window.location.hostname.match( + /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ + ) +); + +export default function register () { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { + // The URL constructor is available in all browsers that support SW. + const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + if (publicUrl.origin !== window.location.origin) { + // Our service worker won't work if PUBLIC_URL is on a different origin + // from what our page is served on. This might happen if a CDN is used to + // serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374 + return; + } + + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + + if (isLocalhost) { + // This is running on localhost. Lets check if a service worker still exists or not. + checkValidServiceWorker(swUrl); + } else { + // Is not local host. Just register service worker + registerValidSW(swUrl); + } + }); + } +} + +function registerValidSW (swUrl) { + navigator.serviceWorker + .register(swUrl) + .then(registration => { + registration.onupdatefound = () => { + const installingWorker = registration.installing; + installingWorker.onstatechange = () => { + if (installingWorker.state === 'installed') { + if (navigator.serviceWorker.controller) { + // At this point, the old content will have been purged and + // the fresh content will have been added to the cache. + // It's the perfect time to display a "New content is + // available; please refresh." message in your web app. + console.log('New content is available; please refresh.'); + } else { + // At this point, everything has been precached. + // It's the perfect time to display a + // "Content is cached for offline use." message. + console.log('Content is cached for offline use.'); + } + } + }; + }; + }) + .catch(error => { + console.error('Error during service worker registration:', error); + }); +} + +function checkValidServiceWorker (swUrl) { + // Check if the service worker can be found. If it can't reload the page. + fetch(swUrl) + .then(response => { + // Ensure service worker exists, and that we really are getting a JS file. + if ( + response.status === 404 || + response.headers.get('content-type').indexOf('javascript') === -1 + ) { + // No service worker found. Probably a different app. Reload the page. + navigator.serviceWorker.ready.then(registration => { + registration.unregister().then(() => { + window.location.reload(); + }); + }); + } else { + // Service worker found. Proceed as normal. + registerValidSW(swUrl); + } + }) + .catch(() => { + console.log( + 'No internet connection found. App is running in offline mode.' + ); + }); +} + +export function unregister () { + if ('serviceWorker' in navigator) { + navigator.serviceWorker.ready.then(registration => { + registration.unregister(); + }); + } +} diff --git a/Project1/ClientApp/src/setupProxy.js b/Project1/ClientApp/src/setupProxy.js new file mode 100644 index 000000000..06e9ad35d --- /dev/null +++ b/Project1/ClientApp/src/setupProxy.js @@ -0,0 +1,14 @@ +const createProxyMiddleware = require('http-proxy-middleware'); + +const context = [ + "/weatherforecast", +]; + +module.exports = function(app) { + const appProxy = createProxyMiddleware(context, { + target: 'http://localhost:5000', + secure: false + }); + + app.use(appProxy); +}; diff --git a/src/GraphQL.Relay.Todo/Controllers/WeatherForecastController.cs b/Project1/Controllers/WeatherForecastController.cs similarity index 96% rename from src/GraphQL.Relay.Todo/Controllers/WeatherForecastController.cs rename to Project1/Controllers/WeatherForecastController.cs index f489cf4e5..d53bc37bf 100644 --- a/src/GraphQL.Relay.Todo/Controllers/WeatherForecastController.cs +++ b/Project1/Controllers/WeatherForecastController.cs @@ -5,7 +5,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; -namespace GraphQL.Relay.Todo.Controllers +namespace Project1.Controllers { [ApiController] [Route("[controller]")] diff --git a/Project1/Pages/Error.cshtml b/Project1/Pages/Error.cshtml new file mode 100644 index 000000000..6f92b9565 --- /dev/null +++ b/Project1/Pages/Error.cshtml @@ -0,0 +1,26 @@ +@page +@model ErrorModel +@{ + ViewData["Title"] = "Error"; +} + +

Error.

+

An error occurred while processing your request.

+ +@if (Model.ShowRequestId) +{ +

+ Request ID: @Model.RequestId +

+} + +

Development Mode

+

+ Swapping to the Development environment displays detailed information about the error that occurred. +

+

+ The Development environment shouldn't be enabled for deployed applications. + It can result in displaying sensitive information from exceptions to end users. + For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development + and restarting the app. +

diff --git a/Project1/Pages/Error.cshtml.cs b/Project1/Pages/Error.cshtml.cs new file mode 100644 index 000000000..cbd795512 --- /dev/null +++ b/Project1/Pages/Error.cshtml.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.Extensions.Logging; + +namespace Project1.Pages +{ + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + public class ErrorModel : PageModel + { + private readonly ILogger _logger; + + public ErrorModel(ILogger logger) + { + _logger = logger; + } + + public string RequestId { get; set; } + + public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); + + public void OnGet() + { + RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; + } + } +} diff --git a/Project1/Pages/_ViewImports.cshtml b/Project1/Pages/_ViewImports.cshtml new file mode 100644 index 000000000..1a491b8e9 --- /dev/null +++ b/Project1/Pages/_ViewImports.cshtml @@ -0,0 +1,3 @@ +@using Project1 +@namespace Project1.Pages +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/Project1/Program.cs b/Project1/Program.cs new file mode 100644 index 000000000..1b83b7847 --- /dev/null +++ b/Project1/Program.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; + +namespace Project1 +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }); + } +} diff --git a/Project1/Project1.csproj b/Project1/Project1.csproj new file mode 100644 index 000000000..c27039b9e --- /dev/null +++ b/Project1/Project1.csproj @@ -0,0 +1,57 @@ + + + + net6.0 + true + Latest + false + ClientApp\ + $(DefaultItemExcludes);$(SpaRoot)node_modules\** + http://localhost:5002 + npm start + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + wwwroot\%(RecursiveDir)%(FileName)%(Extension) + PreserveNewest + true + + + + + diff --git a/Project1/Properties/launchSettings.json b/Project1/Properties/launchSettings.json new file mode 100644 index 000000000..3488f4cfb --- /dev/null +++ b/Project1/Properties/launchSettings.json @@ -0,0 +1,30 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:7976", + "sslPort": 0 + } + }, + "profiles": { + "Project1": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "http://localhost:5002", + "applicationUrl": "http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy" + } + } + } +} diff --git a/Project1/Startup.cs b/Project1/Startup.cs new file mode 100644 index 000000000..f6a5f2b68 --- /dev/null +++ b/Project1/Startup.cs @@ -0,0 +1,50 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace Project1 +{ + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + + services.AddControllersWithViews(); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + else + { + app.UseExceptionHandler("/Error"); + } + + app.UseStaticFiles(); + app.UseRouting(); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllerRoute( + name: "default", + pattern: "{controller}/{action=Index}/{id?}"); + + endpoints.MapFallbackToFile("index.html"); + }); + } + } +} diff --git a/src/GraphQL.Relay.Todo/WeatherForecast.cs b/Project1/WeatherForecast.cs similarity index 90% rename from src/GraphQL.Relay.Todo/WeatherForecast.cs rename to Project1/WeatherForecast.cs index 0be045dd5..861037ab9 100644 --- a/src/GraphQL.Relay.Todo/WeatherForecast.cs +++ b/Project1/WeatherForecast.cs @@ -1,6 +1,6 @@ using System; -namespace GraphQL.Relay.Todo +namespace Project1 { public class WeatherForecast { diff --git a/Project1/appsettings.Development.json b/Project1/appsettings.Development.json new file mode 100644 index 000000000..84308c97f --- /dev/null +++ b/Project1/appsettings.Development.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.AspNetCore.SpaProxy": "Information", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/Project1/appsettings.json b/Project1/appsettings.json new file mode 100644 index 000000000..ad75fee41 --- /dev/null +++ b/Project1/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, +"AllowedHosts": "*" +} diff --git a/src/GraphQL.Relay.Todo/ClientApp/__generated__/appQuery.graphql.js b/src/GraphQL.Relay.Todo/ClientApp/__generated__/appQuery.graphql.js deleted file mode 100644 index 0e7c4d7df..000000000 --- a/src/GraphQL.Relay.Todo/ClientApp/__generated__/appQuery.graphql.js +++ /dev/null @@ -1,331 +0,0 @@ -/** - * @flow - * @relayHash 668b3cdb99f4e71e393d1a1449b7b808 - */ - -/* eslint-disable */ - -'use strict'; - -/*:: -import type {ConcreteBatch} from 'relay-runtime'; -export type appQueryResponse = {| - +viewer: ?{| |}; -|}; -*/ - - -/* -query appQuery { - viewer { - ...TodoApp_viewer - id - } -} - -fragment TodoApp_viewer on User { - id - totalCount - ...TodoListFooter_viewer - ...TodoList_viewer -} - -fragment TodoListFooter_viewer on User { - id - completedCount - completedTodos: todos(status: "completed", first: 2147483647) { - edges { - node { - id - complete - } - } - } - totalCount -} - -fragment TodoList_viewer on User { - todos(first: 2147483647) { - edges { - node { - __typename - id - complete - ...Todo_todo - } - cursor - } - pageInfo { - endCursor - hasNextPage - } - } - id - totalCount - completedCount - ...Todo_viewer -} - -fragment Todo_todo on Todo { - id - complete - text -} - -fragment Todo_viewer on User { - id - totalCount - completedCount -} -*/ - -const batch /*: ConcreteBatch*/ = { - "fragment": { - "argumentDefinitions": [], - "kind": "Fragment", - "metadata": null, - "name": "appQuery", - "selections": [ - { - "kind": "LinkedField", - "alias": null, - "args": null, - "concreteType": "User", - "name": "viewer", - "plural": false, - "selections": [ - { - "kind": "FragmentSpread", - "name": "TodoApp_viewer", - "args": null - } - ], - "storageKey": null - } - ], - "type": "Query" - }, - "id": null, - "kind": "Batch", - "metadata": {}, - "name": "appQuery", - "query": { - "argumentDefinitions": [], - "kind": "Root", - "name": "appQuery", - "operation": "query", - "selections": [ - { - "kind": "LinkedField", - "alias": null, - "args": null, - "concreteType": "User", - "name": "viewer", - "plural": false, - "selections": [ - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "id", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "totalCount", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "completedCount", - "storageKey": null - }, - { - "kind": "LinkedField", - "alias": "completedTodos", - "args": [ - { - "kind": "Literal", - "name": "first", - "value": 2147483647, - "type": "Int" - }, - { - "kind": "Literal", - "name": "status", - "value": "completed", - "type": "String" - } - ], - "concreteType": "TodoConnection", - "name": "todos", - "plural": false, - "selections": [ - { - "kind": "LinkedField", - "alias": null, - "args": null, - "concreteType": "TodoEdge", - "name": "edges", - "plural": true, - "selections": [ - { - "kind": "LinkedField", - "alias": null, - "args": null, - "concreteType": "Todo", - "name": "node", - "plural": false, - "selections": [ - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "id", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "complete", - "storageKey": null - } - ], - "storageKey": null - } - ], - "storageKey": null - } - ], - "storageKey": "todos{\"first\":2147483647,\"status\":\"completed\"}" - }, - { - "kind": "LinkedField", - "alias": null, - "args": [ - { - "kind": "Literal", - "name": "first", - "value": 2147483647, - "type": "Int" - } - ], - "concreteType": "TodoConnection", - "name": "todos", - "plural": false, - "selections": [ - { - "kind": "LinkedField", - "alias": null, - "args": null, - "concreteType": "TodoEdge", - "name": "edges", - "plural": true, - "selections": [ - { - "kind": "LinkedField", - "alias": null, - "args": null, - "concreteType": "Todo", - "name": "node", - "plural": false, - "selections": [ - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "__typename", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "id", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "complete", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "text", - "storageKey": null - } - ], - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "cursor", - "storageKey": null - } - ], - "storageKey": null - }, - { - "kind": "LinkedField", - "alias": null, - "args": null, - "concreteType": "PageInfo", - "name": "pageInfo", - "plural": false, - "selections": [ - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "endCursor", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "hasNextPage", - "storageKey": null - } - ], - "storageKey": null - } - ], - "storageKey": "todos{\"first\":2147483647}" - }, - { - "kind": "LinkedHandle", - "alias": null, - "args": [ - { - "kind": "Literal", - "name": "first", - "value": 2147483647, - "type": "Int" - } - ], - "handle": "connection", - "name": "todos", - "key": "TodoList_todos", - "filters": null - } - ], - "storageKey": null - } - ] - }, - "text": "query appQuery {\n viewer {\n ...TodoApp_viewer\n id\n }\n}\n\nfragment TodoApp_viewer on User {\n id\n totalCount\n ...TodoListFooter_viewer\n ...TodoList_viewer\n}\n\nfragment TodoListFooter_viewer on User {\n id\n completedCount\n completedTodos: todos(status: \"completed\", first: 2147483647) {\n edges {\n node {\n id\n complete\n }\n }\n }\n totalCount\n}\n\nfragment TodoList_viewer on User {\n todos(first: 2147483647) {\n edges {\n node {\n __typename\n id\n complete\n ...Todo_todo\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n id\n totalCount\n completedCount\n ...Todo_viewer\n}\n\nfragment Todo_todo on Todo {\n id\n complete\n text\n}\n\nfragment Todo_viewer on User {\n id\n totalCount\n completedCount\n}\n" -}; - -module.exports = batch; diff --git a/src/GraphQL.Relay.Todo/ClientApp/app.js b/src/GraphQL.Relay.Todo/ClientApp/app.js deleted file mode 100644 index ba796243b..000000000 --- a/src/GraphQL.Relay.Todo/ClientApp/app.js +++ /dev/null @@ -1,79 +0,0 @@ -/** - * This file provided by Facebook is for non-commercial testing and evaluation - * purposes only. Facebook reserves all rights not expressly granted. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import 'todomvc-common'; -import './css/base.css'; -import './css/index.css'; - -import React from 'react'; -import ReactDOM from 'react-dom'; - -import { - QueryRenderer, - graphql, -} from 'react-relay'; -import { - Environment, - Network, - RecordSource, - Store, -} from 'relay-runtime'; - -import TodoApp from './components/TodoApp'; - - -const mountNode = document.getElementById('root'); - -function fetchQuery( - operation, - variables, -) { - return fetch('/graphql', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - query: operation.text, - variables, - }), - }).then(response => { - return response.json(); - }); -} - -const modernEnvironment = new Environment({ - network: Network.create(fetchQuery), - store: new Store(new RecordSource()), -}); - -ReactDOM.render( - { - if (props) { - return ; - } else { - return
Loading
; - } - }} - />, - mountNode -); diff --git a/src/GraphQL.Relay.Todo/ClientApp/components/TodoList.js b/src/GraphQL.Relay.Todo/ClientApp/components/TodoList.js deleted file mode 100644 index 27220805b..000000000 --- a/src/GraphQL.Relay.Todo/ClientApp/components/TodoList.js +++ /dev/null @@ -1,78 +0,0 @@ -/** - * This file provided by Facebook is for non-commercial testing and evaluation - * purposes only. Facebook reserves all rights not expressly granted. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import MarkAllTodosMutation from '../mutations/MarkAllTodosMutation' -import Todo from './Todo' - -import React from 'react' -import { createFragmentContainer, graphql } from 'react-relay' - -class TodoList extends React.Component { - _handleMarkAllChange = e => { - const complete = e.target.checked - MarkAllTodosMutation.commit( - this.props.relay.environment, - complete, - this.props.viewer.todos, - this.props.viewer - ) - } - - renderTodos() { - return this.props.viewer.todos.edges.map(edge => ( - - )) - } - - render() { - const numTodos = this.props.viewer.totalCount - const numCompletedTodos = this.props.viewer.completedCount - return ( -
- - -
    {this.renderTodos()}
-
- ) - } -} - -export default createFragmentContainer(TodoList, { - viewer: graphql` - fragment TodoList_viewer on User { - todos( - first: 2147483647 # max GraphQLInt - ) @connection(key: "TodoList_todos") { - edges { - node { - id - complete - ...Todo_todo - } - } - } - id - totalCount - completedCount - ...Todo_viewer - } - `, -}) diff --git a/src/GraphQL.Relay.Todo/ClientApp/components/TodoListFooter.js b/src/GraphQL.Relay.Todo/ClientApp/components/TodoListFooter.js deleted file mode 100644 index a2d103437..000000000 --- a/src/GraphQL.Relay.Todo/ClientApp/components/TodoListFooter.js +++ /dev/null @@ -1,69 +0,0 @@ -/** - * This file provided by Facebook is for non-commercial testing and evaluation - * purposes only. Facebook reserves all rights not expressly granted. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import RemoveCompletedTodosMutation from '../mutations/RemoveCompletedTodosMutation'; - -import React from 'react'; -import { - graphql, - createFragmentContainer, -} from 'react-relay'; - -class TodoListFooter extends React.Component { - _handleRemoveCompletedTodosClick = () => { - RemoveCompletedTodosMutation.commit( - this.props.relay.environment, - this.props.viewer.completedTodos, - this.props.viewer, - ); - }; - render() { - const numCompletedTodos = this.props.viewer.completedCount; - const numRemainingTodos = this.props.viewer.totalCount - numCompletedTodos; - return ( -
- - {numRemainingTodos} item{numRemainingTodos === 1 ? '' : 's'} left - - {numCompletedTodos > 0 && - - } -
- ); - } -} - -export default createFragmentContainer( - TodoListFooter, - graphql` - fragment TodoListFooter_viewer on User { - id, - completedCount, - completedTodos: todos( - status: "completed", - first: 2147483647 # max GraphQLInt - ) { - edges { - node { - id - complete - } - } - }, - totalCount, - } - ` -); diff --git a/src/GraphQL.Relay.Todo/ClientApp/components/TodoTextInput.js b/src/GraphQL.Relay.Todo/ClientApp/components/TodoTextInput.js deleted file mode 100644 index 5f96a388d..000000000 --- a/src/GraphQL.Relay.Todo/ClientApp/components/TodoTextInput.js +++ /dev/null @@ -1,79 +0,0 @@ -/** - * This file provided by Facebook is for non-commercial testing and evaluation - * purposes only. Facebook reserves all rights not expressly granted. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import React from 'react'; -import ReactDOM from 'react-dom'; - -const PropTypes = require('prop-types'); - -const ENTER_KEY_CODE = 13; -const ESC_KEY_CODE = 27; - -export default class TodoTextInput extends React.Component { - static defaultProps = { - commitOnBlur: false, - }; - static propTypes = { - className: PropTypes.string, - commitOnBlur: PropTypes.bool.isRequired, - initialValue: PropTypes.string, - onCancel: PropTypes.func, - onDelete: PropTypes.func, - onSave: PropTypes.func.isRequired, - placeholder: PropTypes.string, - }; - state = { - isEditing: false, - text: this.props.initialValue || '', - }; - componentDidMount() { - ReactDOM.findDOMNode(this).focus(); - } - _commitChanges = () => { - const newText = this.state.text.trim(); - if (this.props.onDelete && newText === '') { - this.props.onDelete(); - } else if (this.props.onCancel && newText === this.props.initialValue) { - this.props.onCancel(); - } else if (newText !== '') { - this.props.onSave(newText); - this.setState({text: ''}); - } - }; - _handleBlur = () => { - if (this.props.commitOnBlur) { - this._commitChanges(); - } - }; - _handleChange = (e) => { - this.setState({text: e.target.value}); - }; - _handleKeyDown = (e) => { - if (this.props.onCancel && e.keyCode === ESC_KEY_CODE) { - this.props.onCancel(); - } else if (e.keyCode === ENTER_KEY_CODE) { - this._commitChanges(); - } - }; - render() { - return ( - - ); - } -} diff --git a/src/GraphQL.Relay.Todo/ClientApp/components/__generated__/Todo_todo.graphql.js b/src/GraphQL.Relay.Todo/ClientApp/components/__generated__/Todo_todo.graphql.js deleted file mode 100644 index 111948fc3..000000000 --- a/src/GraphQL.Relay.Todo/ClientApp/components/__generated__/Todo_todo.graphql.js +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @flow - */ - -/* eslint-disable */ - -'use strict'; - -/*:: -import type {ConcreteFragment} from 'relay-runtime'; -export type Todo_todo = {| - +id: string; - +complete: boolean; - +text: string; -|}; -*/ - - -const fragment /*: ConcreteFragment*/ = { - "argumentDefinitions": [], - "kind": "Fragment", - "metadata": null, - "name": "Todo_todo", - "selections": [ - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "id", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "complete", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "text", - "storageKey": null - } - ], - "type": "Todo" -}; - -module.exports = fragment; diff --git a/src/GraphQL.Relay.Todo/ClientApp/components/__generated__/Todo_viewer.graphql.js b/src/GraphQL.Relay.Todo/ClientApp/components/__generated__/Todo_viewer.graphql.js deleted file mode 100644 index f797e50a4..000000000 --- a/src/GraphQL.Relay.Todo/ClientApp/components/__generated__/Todo_viewer.graphql.js +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @flow - */ - -/* eslint-disable */ - -'use strict'; - -/*:: -import type {ConcreteFragment} from 'relay-runtime'; -export type Todo_viewer = {| - +id: string; - +totalCount: ?number; - +completedCount: ?number; -|}; -*/ - - -const fragment /*: ConcreteFragment*/ = { - "argumentDefinitions": [], - "kind": "Fragment", - "metadata": null, - "name": "Todo_viewer", - "selections": [ - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "id", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "totalCount", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "completedCount", - "storageKey": null - } - ], - "type": "User" -}; - -module.exports = fragment; diff --git a/src/GraphQL.Relay.Todo/ClientApp/css/base.css b/src/GraphQL.Relay.Todo/ClientApp/css/base.css deleted file mode 100644 index da65968a7..000000000 --- a/src/GraphQL.Relay.Todo/ClientApp/css/base.css +++ /dev/null @@ -1,141 +0,0 @@ -hr { - margin: 20px 0; - border: 0; - border-top: 1px dashed #c5c5c5; - border-bottom: 1px dashed #f7f7f7; -} - -.learn a { - font-weight: normal; - text-decoration: none; - color: #b83f45; -} - -.learn a:hover { - text-decoration: underline; - color: #787e7e; -} - -.learn h3, -.learn h4, -.learn h5 { - margin: 10px 0; - font-weight: 500; - line-height: 1.2; - color: #000; -} - -.learn h3 { - font-size: 24px; -} - -.learn h4 { - font-size: 18px; -} - -.learn h5 { - margin-bottom: 0; - font-size: 14px; -} - -.learn ul { - padding: 0; - margin: 0 0 30px 25px; -} - -.learn li { - line-height: 20px; -} - -.learn p { - font-size: 15px; - font-weight: 300; - line-height: 1.3; - margin-top: 0; - margin-bottom: 0; -} - -#issue-count { - display: none; -} - -.quote { - border: none; - margin: 20px 0 60px 0; -} - -.quote p { - font-style: italic; -} - -.quote p:before { - content: '“'; - font-size: 50px; - opacity: .15; - position: absolute; - top: -20px; - left: 3px; -} - -.quote p:after { - content: '”'; - font-size: 50px; - opacity: .15; - position: absolute; - bottom: -42px; - right: 3px; -} - -.quote footer { - position: absolute; - bottom: -40px; - right: 0; -} - -.quote footer img { - border-radius: 3px; -} - -.quote footer a { - margin-left: 5px; - vertical-align: middle; -} - -.speech-bubble { - position: relative; - padding: 10px; - background: rgba(0, 0, 0, .04); - border-radius: 5px; -} - -.speech-bubble:after { - content: ''; - position: absolute; - top: 100%; - right: 30px; - border: 13px solid transparent; - border-top-color: rgba(0, 0, 0, .04); -} - -.learn-bar > .learn { - position: absolute; - width: 272px; - top: 8px; - left: -300px; - padding: 10px; - border-radius: 5px; - background-color: rgba(255, 255, 255, .6); - transition-property: left; - transition-duration: 500ms; -} - -@media (min-width: 899px) { - .learn-bar { - width: auto; - padding-left: 300px; - } - - .learn-bar > .learn { - left: 8px; - } -} diff --git a/src/GraphQL.Relay.Todo/ClientApp/css/index.css b/src/GraphQL.Relay.Todo/ClientApp/css/index.css deleted file mode 100644 index b45de0d0f..000000000 --- a/src/GraphQL.Relay.Todo/ClientApp/css/index.css +++ /dev/null @@ -1,370 +0,0 @@ -html, -body { - margin: 0; - padding: 0; -} - -button { - margin: 0; - padding: 0; - border: 0; - background: none; - font-size: 100%; - vertical-align: baseline; - font-family: inherit; - font-weight: inherit; - color: inherit; - -webkit-appearance: none; - appearance: none; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -body { - font: 14px 'Helvetica Neue', Helvetica, Arial, sans-serif; - line-height: 1.4em; - background: #f5f5f5; - color: #4d4d4d; - min-width: 230px; - max-width: 550px; - margin: 0 auto; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; - font-weight: 300; -} - -:focus { - outline: 0; -} - -.hidden { - display: none; -} - -.todoapp { - background: #fff; - margin: 130px 0 40px 0; - position: relative; - box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), - 0 25px 50px 0 rgba(0, 0, 0, 0.1); -} - -.todoapp input::-webkit-input-placeholder { - font-style: italic; - font-weight: 300; - color: #e6e6e6; -} - -.todoapp input::-moz-placeholder { - font-style: italic; - font-weight: 300; - color: #e6e6e6; -} - -.todoapp input::input-placeholder { - font-style: italic; - font-weight: 300; - color: #e6e6e6; -} - -.todoapp h1 { - position: absolute; - top: -155px; - width: 100%; - font-size: 100px; - font-weight: 100; - text-align: center; - color: rgba(175, 47, 47, 0.15); - -webkit-text-rendering: optimizeLegibility; - -moz-text-rendering: optimizeLegibility; - text-rendering: optimizeLegibility; -} - -.new-todo, -.edit { - position: relative; - margin: 0; - width: 100%; - font-size: 24px; - font-family: inherit; - font-weight: inherit; - line-height: 1.4em; - border: 0; - color: inherit; - padding: 6px; - border: 1px solid #999; - box-shadow: inset 0 -1px 5px 0 rgba(0, 0, 0, 0.2); - box-sizing: border-box; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -.new-todo { - padding: 16px 16px 16px 60px; - border: none; - background: rgba(0, 0, 0, 0.003); - box-shadow: inset 0 -2px 1px rgba(0,0,0,0.03); -} - -.main { - position: relative; - z-index: 2; - border-top: 1px solid #e6e6e6; -} - -label[for='toggle-all'] { - display: none; -} - -.toggle-all { - position: absolute; - top: -55px; - left: -12px; - width: 60px; - height: 34px; - text-align: center; - border: none; /* Mobile Safari */ -} - -.toggle-all:before { - content: '❯'; - font-size: 22px; - color: #e6e6e6; - padding: 10px 27px 10px 27px; -} - -.toggle-all:checked:before { - color: #737373; -} - -.todo-list { - margin: 0; - padding: 0; - list-style: none; -} - -.todo-list li { - position: relative; - font-size: 24px; - border-bottom: 1px solid #ededed; -} - -.todo-list li:last-child { - border-bottom: none; -} - -.todo-list li.editing { - border-bottom: none; - padding: 0; -} - -.todo-list li.editing .edit { - display: block; - width: 506px; - padding: 12px 16px; - margin: 0 0 0 43px; -} - -.todo-list li.editing .view { - display: none; -} - -.todo-list li .toggle { - text-align: center; - width: 40px; - /* auto, since non-WebKit browsers doesn't support input styling */ - height: auto; - position: absolute; - top: 0; - bottom: 0; - margin: auto 0; - border: none; /* Mobile Safari */ - -webkit-appearance: none; - appearance: none; -} - -.todo-list li .toggle:after { - content: url('data:image/svg+xml;utf8,'); -} - -.todo-list li .toggle:checked:after { - content: url('data:image/svg+xml;utf8,'); -} - -.todo-list li label { - word-break: break-all; - padding: 15px 60px 15px 15px; - margin-left: 45px; - display: block; - line-height: 1.2; - transition: color 0.4s; -} - -.todo-list li.completed label { - color: #d9d9d9; - text-decoration: line-through; -} - -.todo-list li .destroy { - display: none; - position: absolute; - top: 0; - right: 10px; - bottom: 0; - width: 40px; - height: 40px; - margin: auto 0; - font-size: 30px; - color: #cc9a9a; - margin-bottom: 11px; - transition: color 0.2s ease-out; -} - -.todo-list li .destroy:hover { - color: #af5b5e; -} - -.todo-list li .destroy:after { - content: '×'; -} - -.todo-list li:hover .destroy { - display: block; -} - -.todo-list li .edit { - display: none; -} - -.todo-list li.editing:last-child { - margin-bottom: -1px; -} - -.footer { - color: #777; - padding: 10px 15px; - height: 20px; - text-align: center; - border-top: 1px solid #e6e6e6; -} - -.footer:before { - content: ''; - position: absolute; - right: 0; - bottom: 0; - left: 0; - height: 50px; - overflow: hidden; - box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2), - 0 8px 0 -3px #f6f6f6, - 0 9px 1px -3px rgba(0, 0, 0, 0.2), - 0 16px 0 -6px #f6f6f6, - 0 17px 2px -6px rgba(0, 0, 0, 0.2); -} - -.todo-count { - float: left; - text-align: left; -} - -.todo-count strong { - font-weight: 300; -} - -.filters { - margin: 0; - padding: 0; - list-style: none; - position: absolute; - right: 0; - left: 0; -} - -.filters li { - display: inline; -} - -.filters li a { - color: inherit; - margin: 3px; - padding: 3px 7px; - text-decoration: none; - border: 1px solid transparent; - border-radius: 3px; -} - -.filters li a:hover { - border-color: rgba(175, 47, 47, 0.1); -} - -.filters li a.selected { - border-color: rgba(175, 47, 47, 0.2); -} - -.clear-completed, -html .clear-completed:active { - float: right; - position: relative; - line-height: 20px; - text-decoration: none; - cursor: pointer; -} - -.clear-completed:hover { - text-decoration: underline; -} - -.info { - margin: 65px auto 0; - color: #bfbfbf; - font-size: 10px; - text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); - text-align: center; -} - -.info p { - line-height: 1; -} - -.info a { - color: inherit; - text-decoration: none; - font-weight: 400; -} - -.info a:hover { - text-decoration: underline; -} - -/* - Hack to remove background from Mobile Safari. - Can't use it globally since it destroys checkboxes in Firefox -*/ -@media screen and (-webkit-min-device-pixel-ratio:0) { - .toggle-all, - .todo-list li .toggle { - background: none; - } - - .todo-list li .toggle { - height: 40px; - } - - .toggle-all { - -webkit-transform: rotate(90deg); - transform: rotate(90deg); - -webkit-appearance: none; - appearance: none; - } -} - -@media (max-width: 430px) { - .footer { - height: 50px; - } - - .filters { - bottom: 10px; - } -} diff --git a/src/GraphQL.Relay.Todo/ClientApp/mutations/AddTodoMutation.js b/src/GraphQL.Relay.Todo/ClientApp/mutations/AddTodoMutation.js deleted file mode 100644 index cde259c2a..000000000 --- a/src/GraphQL.Relay.Todo/ClientApp/mutations/AddTodoMutation.js +++ /dev/null @@ -1,92 +0,0 @@ -/** - * This file provided by Facebook is for non-commercial testing and evaluation - * purposes only. Facebook reserves all rights not expressly granted. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import { - commitMutation, - graphql, -} from 'react-relay'; -import {ConnectionHandler} from 'relay-runtime'; - -const mutation = graphql` - mutation AddTodoMutation($input: AddTodoInput!) { - addTodo(input:$input) { - todoEdge { - __typename - cursor - node { - id - complete - text - } - } - viewer { - id - totalCount - } - } - } -`; - -function sharedUpdater(store, user, newEdge) { - const userProxy = store.get(user.id); - const conn = ConnectionHandler.getConnection( - userProxy, - 'TodoList_todos', - ); - ConnectionHandler.insertEdgeAfter(conn, newEdge); -} - -let tempID = 0; - -function commit( - environment, - text, - user -) { - return commitMutation( - environment, - { - mutation, - variables: { - input: { - text, - clientMutationId: tempID++, - }, - }, - updater: (store) => { - const payload = store.getRootField('addTodo'); - const newEdge = payload.getLinkedRecord('todoEdge'); - sharedUpdater(store, user, newEdge); - }, - optimisticUpdater: (store) => { - const id = 'client:newTodo:' + tempID++; - const node = store.create(id, 'Todo'); - node.setValue(text, 'text'); - node.setValue(id, 'id'); - - const newEdge = store.create( - 'client:newEdge:' + tempID++, - 'TodoEdge', - ); - newEdge.setLinkedRecord(node, 'node'); - sharedUpdater(store, user, newEdge); - const userProxy = store.get(user.id); - userProxy.setValue( - userProxy.getValue('totalCount') + 1, - 'totalCount', - ); - }, - } - ); -} - -export default {commit}; diff --git a/src/GraphQL.Relay.Todo/ClientApp/mutations/ChangeTodoStatusMutation.js b/src/GraphQL.Relay.Todo/ClientApp/mutations/ChangeTodoStatusMutation.js deleted file mode 100644 index c0fcdf932..000000000 --- a/src/GraphQL.Relay.Todo/ClientApp/mutations/ChangeTodoStatusMutation.js +++ /dev/null @@ -1,58 +0,0 @@ -/** - * This file provided by Facebook is for non-commercial testing and evaluation - * purposes only. Facebook reserves all rights not expressly granted. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import { commitMutation, graphql } from 'react-relay' - -const mutation = graphql` - mutation ChangeTodoStatusMutation($input: ChangeTodoStatusInput!) { - changeTodoStatus(input: $input) { - todo { - todoId - complete - } - viewer { - id - completedCount - } - } - } -` - -function getOptimisticResponse(complete, todo, user) { - const viewerPayload = { id: user.id } - if (user.completedCount != null) { - viewerPayload.completedCount = complete - ? user.completedCount + 1 - : user.completedCount - 1 - } - return { - changeTodoStatus: { - todo: { - complete: complete, - id: todo.id, - }, - viewer: viewerPayload, - }, - } -} - -function commit(environment, complete, todo, user) { - return commitMutation(environment, { - mutation, - variables: { - input: { complete, id: todo.id }, - }, - optimisticResponse: getOptimisticResponse(complete, todo, user), - }) -} - -export default { commit } diff --git a/src/GraphQL.Relay.Todo/ClientApp/mutations/MarkAllTodosMutation.js b/src/GraphQL.Relay.Todo/ClientApp/mutations/MarkAllTodosMutation.js deleted file mode 100644 index bb624fb70..000000000 --- a/src/GraphQL.Relay.Todo/ClientApp/mutations/MarkAllTodosMutation.js +++ /dev/null @@ -1,58 +0,0 @@ -/** - * This file provided by Facebook is for non-commercial testing and evaluation - * purposes only. Facebook reserves all rights not expressly granted. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import { commitMutation, graphql } from 'react-relay' - -const mutation = graphql` - mutation MarkAllTodosMutation($input: MarkAllTodosInput!) { - markAllTodos(input: $input) { - changedTodos { - id - complete - } - viewer { - id - completedCount - } - } - } -` - -function getOptimisticResponse(complete, todos, user) { - const payload = { viewer: { id: user.id } } - if (todos && todos.edges) { - payload.changedTodos = todos.edges - .filter(edge => edge.node.complete !== complete) - .map(edge => ({ - complete: complete, - id: edge.node.id, - })) - } - if (user.totalCount != null) { - payload.viewer.completedCount = complete ? user.totalCount : 0 - } - return { - markAllTodos: payload, - } -} - -function commit(environment, complete, todos, user) { - return commitMutation(environment, { - mutation, - variables: { - input: { complete }, - }, - optimisticResponse: getOptimisticResponse(complete, todos, user), - }) -} - -export default { commit } diff --git a/src/GraphQL.Relay.Todo/ClientApp/mutations/RemoveCompletedTodosMutation.js b/src/GraphQL.Relay.Todo/ClientApp/mutations/RemoveCompletedTodosMutation.js deleted file mode 100644 index 7aaed2007..000000000 --- a/src/GraphQL.Relay.Todo/ClientApp/mutations/RemoveCompletedTodosMutation.js +++ /dev/null @@ -1,70 +0,0 @@ -/** - * This file provided by Facebook is for non-commercial testing and evaluation - * purposes only. Facebook reserves all rights not expressly granted. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import { - commitMutation, - graphql, -} from 'react-relay'; -import {ConnectionHandler} from 'relay-runtime'; - -const mutation = graphql` - mutation RemoveCompletedTodosMutation($input: RemoveCompletedTodosInput!) { - removeCompletedTodos(input: $input) { - deletedTodoIds, - viewer { - completedCount, - totalCount, - }, - } - } -`; - -function sharedUpdater(store, user, deletedIDs) { - const userProxy = store.get(user.id); - const conn = ConnectionHandler.getConnection( - userProxy, - 'TodoList_todos', - ); - deletedIDs.forEach((deletedID) => - ConnectionHandler.deleteNode(conn, deletedID) - ); -} - -function commit( - environment, - todos, - user, -) { - return commitMutation( - environment, - { - mutation, - variables: { - input: {}, - }, - updater: (store) => { - const payload = store.getRootField('removeCompletedTodos'); - sharedUpdater(store, user, payload.getValue('deletedTodoIds')); - }, - optimisticUpdater: (store) => { - if (todos && todos.edges) { - const deletedIDs = todos.edges - .filter(edge => edge.node.complete) - .map(edge => edge.node.id); - sharedUpdater(store, user, deletedIDs); - } - }, - } - ); -} - -export default {commit}; diff --git a/src/GraphQL.Relay.Todo/ClientApp/mutations/RemoveTodoMutation.js b/src/GraphQL.Relay.Todo/ClientApp/mutations/RemoveTodoMutation.js deleted file mode 100644 index d4039e17b..000000000 --- a/src/GraphQL.Relay.Todo/ClientApp/mutations/RemoveTodoMutation.js +++ /dev/null @@ -1,50 +0,0 @@ -/** - * This file provided by Facebook is for non-commercial testing and evaluation - * purposes only. Facebook reserves all rights not expressly granted. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import { commitMutation, graphql } from 'react-relay' -import { ConnectionHandler } from 'relay-runtime' - -const mutation = graphql` - mutation RemoveTodoMutation($input: RemoveTodoInput!) { - removeTodo(input: $input) { - deletedTodoId - viewer { - completedCount - totalCount - } - } - } -` - -function sharedUpdater(store, user, deletedID) { - const userProxy = store.get(user.id) - const conn = ConnectionHandler.getConnection(userProxy, 'TodoList_todos') - ConnectionHandler.deleteNode(conn, deletedID) -} - -function commit(environment, todo, user) { - return commitMutation(environment, { - mutation, - variables: { - input: { id: todo.id }, - }, - updater: store => { - const payload = store.getRootField('removeTodo') - sharedUpdater(store, user, payload.getValue('deletedTodoId')) - }, - optimisticUpdater: store => { - sharedUpdater(store, user, todo.id) - }, - }) -} - -export default { commit } diff --git a/src/GraphQL.Relay.Todo/ClientApp/mutations/RenameTodoMutation.js b/src/GraphQL.Relay.Todo/ClientApp/mutations/RenameTodoMutation.js deleted file mode 100644 index 818d30a6e..000000000 --- a/src/GraphQL.Relay.Todo/ClientApp/mutations/RenameTodoMutation.js +++ /dev/null @@ -1,47 +0,0 @@ -/** - * This file provided by Facebook is for non-commercial testing and evaluation - * purposes only. Facebook reserves all rights not expressly granted. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import { commitMutation, graphql } from 'react-relay' - -const mutation = graphql` - mutation RenameTodoMutation($input: RenameTodoInput!) { - renameTodo(input: $input) { - todo { - id - text - } - } - } -` - -function getOptimisticResponse(text, todo) { - return { - renameTodo: { - todo: { - id: todo.id, - text: text, - }, - }, - } -} - -function commit(environment, text, todo) { - return commitMutation(environment, { - mutation, - variables: { - input: { text, id: todo.id }, - }, - optimisticResponse: getOptimisticResponse(text, todo), - }) -} - -export default { commit } diff --git a/src/GraphQL.Relay.Todo/ClientApp/mutations/__generated__/ChangeTodoStatusMutation.graphql.js b/src/GraphQL.Relay.Todo/ClientApp/mutations/__generated__/ChangeTodoStatusMutation.graphql.js deleted file mode 100644 index e9d058b2d..000000000 --- a/src/GraphQL.Relay.Todo/ClientApp/mutations/__generated__/ChangeTodoStatusMutation.graphql.js +++ /dev/null @@ -1,234 +0,0 @@ -/** - * @flow - * @relayHash f1e93f4a42cccdfd76aeabfc274034f2 - */ - -/* eslint-disable */ - -'use strict'; - -/*:: -import type {ConcreteBatch} from 'relay-runtime'; -export type ChangeTodoStatusMutationVariables = {| - input: { - clientMutationId?: ?string; - id?: ?string; - complete?: ?boolean; - }; -|}; -export type ChangeTodoStatusMutationResponse = {| - +changeTodoStatus: ?{| - +todo: ?{| - +todoId: string; - +complete: boolean; - |}; - +viewer: ?{| - +id: string; - +completedCount: ?number; - |}; - |}; -|}; -*/ - - -/* -mutation ChangeTodoStatusMutation( - $input: ChangeTodoStatusInput! -) { - changeTodoStatus(input: $input) { - todo { - todoId - complete - id - } - viewer { - id - completedCount - } - } -} -*/ - -const batch /*: ConcreteBatch*/ = { - "fragment": { - "argumentDefinitions": [ - { - "kind": "LocalArgument", - "name": "input", - "type": "ChangeTodoStatusInput!", - "defaultValue": null - } - ], - "kind": "Fragment", - "metadata": null, - "name": "ChangeTodoStatusMutation", - "selections": [ - { - "kind": "LinkedField", - "alias": null, - "args": [ - { - "kind": "Variable", - "name": "input", - "variableName": "input", - "type": "ChangeTodoStatusInput!" - } - ], - "concreteType": "ChangeTodoStatusPayload", - "name": "changeTodoStatus", - "plural": false, - "selections": [ - { - "kind": "LinkedField", - "alias": null, - "args": null, - "concreteType": "Todo", - "name": "todo", - "plural": false, - "selections": [ - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "todoId", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "complete", - "storageKey": null - } - ], - "storageKey": null - }, - { - "kind": "LinkedField", - "alias": null, - "args": null, - "concreteType": "User", - "name": "viewer", - "plural": false, - "selections": [ - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "id", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "completedCount", - "storageKey": null - } - ], - "storageKey": null - } - ], - "storageKey": null - } - ], - "type": "Mutation" - }, - "id": null, - "kind": "Batch", - "metadata": {}, - "name": "ChangeTodoStatusMutation", - "query": { - "argumentDefinitions": [ - { - "kind": "LocalArgument", - "name": "input", - "type": "ChangeTodoStatusInput!", - "defaultValue": null - } - ], - "kind": "Root", - "name": "ChangeTodoStatusMutation", - "operation": "mutation", - "selections": [ - { - "kind": "LinkedField", - "alias": null, - "args": [ - { - "kind": "Variable", - "name": "input", - "variableName": "input", - "type": "ChangeTodoStatusInput!" - } - ], - "concreteType": "ChangeTodoStatusPayload", - "name": "changeTodoStatus", - "plural": false, - "selections": [ - { - "kind": "LinkedField", - "alias": null, - "args": null, - "concreteType": "Todo", - "name": "todo", - "plural": false, - "selections": [ - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "todoId", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "complete", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "id", - "storageKey": null - } - ], - "storageKey": null - }, - { - "kind": "LinkedField", - "alias": null, - "args": null, - "concreteType": "User", - "name": "viewer", - "plural": false, - "selections": [ - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "id", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "completedCount", - "storageKey": null - } - ], - "storageKey": null - } - ], - "storageKey": null - } - ] - }, - "text": "mutation ChangeTodoStatusMutation(\n $input: ChangeTodoStatusInput!\n) {\n changeTodoStatus(input: $input) {\n todo {\n todoId\n complete\n id\n }\n viewer {\n id\n completedCount\n }\n }\n}\n" -}; - -module.exports = batch; diff --git a/src/GraphQL.Relay.Todo/ClientApp/mutations/__generated__/MarkAllTodosMutation.graphql.js b/src/GraphQL.Relay.Todo/ClientApp/mutations/__generated__/MarkAllTodosMutation.graphql.js deleted file mode 100644 index 7da2b6f42..000000000 --- a/src/GraphQL.Relay.Todo/ClientApp/mutations/__generated__/MarkAllTodosMutation.graphql.js +++ /dev/null @@ -1,225 +0,0 @@ -/** - * @flow - * @relayHash ca24d33385a1c8aa0297aee219065972 - */ - -/* eslint-disable */ - -'use strict'; - -/*:: -import type {ConcreteBatch} from 'relay-runtime'; -export type MarkAllTodosMutationVariables = {| - input: { - clientMutationId?: ?string; - complete?: ?boolean; - }; -|}; -export type MarkAllTodosMutationResponse = {| - +markAllTodos: ?{| - +changedTodos: ?$ReadOnlyArray; - +viewer: ?{| - +id: string; - +completedCount: ?number; - |}; - |}; -|}; -*/ - - -/* -mutation MarkAllTodosMutation( - $input: MarkAllTodosInput! -) { - markAllTodos(input: $input) { - changedTodos { - id - complete - } - viewer { - id - completedCount - } - } -} -*/ - -const batch /*: ConcreteBatch*/ = { - "fragment": { - "argumentDefinitions": [ - { - "kind": "LocalArgument", - "name": "input", - "type": "MarkAllTodosInput!", - "defaultValue": null - } - ], - "kind": "Fragment", - "metadata": null, - "name": "MarkAllTodosMutation", - "selections": [ - { - "kind": "LinkedField", - "alias": null, - "args": [ - { - "kind": "Variable", - "name": "input", - "variableName": "input", - "type": "MarkAllTodosInput!" - } - ], - "concreteType": "MarkAllTodosPayload", - "name": "markAllTodos", - "plural": false, - "selections": [ - { - "kind": "LinkedField", - "alias": null, - "args": null, - "concreteType": "Todo", - "name": "changedTodos", - "plural": true, - "selections": [ - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "id", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "complete", - "storageKey": null - } - ], - "storageKey": null - }, - { - "kind": "LinkedField", - "alias": null, - "args": null, - "concreteType": "User", - "name": "viewer", - "plural": false, - "selections": [ - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "id", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "completedCount", - "storageKey": null - } - ], - "storageKey": null - } - ], - "storageKey": null - } - ], - "type": "Mutation" - }, - "id": null, - "kind": "Batch", - "metadata": {}, - "name": "MarkAllTodosMutation", - "query": { - "argumentDefinitions": [ - { - "kind": "LocalArgument", - "name": "input", - "type": "MarkAllTodosInput!", - "defaultValue": null - } - ], - "kind": "Root", - "name": "MarkAllTodosMutation", - "operation": "mutation", - "selections": [ - { - "kind": "LinkedField", - "alias": null, - "args": [ - { - "kind": "Variable", - "name": "input", - "variableName": "input", - "type": "MarkAllTodosInput!" - } - ], - "concreteType": "MarkAllTodosPayload", - "name": "markAllTodos", - "plural": false, - "selections": [ - { - "kind": "LinkedField", - "alias": null, - "args": null, - "concreteType": "Todo", - "name": "changedTodos", - "plural": true, - "selections": [ - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "id", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "complete", - "storageKey": null - } - ], - "storageKey": null - }, - { - "kind": "LinkedField", - "alias": null, - "args": null, - "concreteType": "User", - "name": "viewer", - "plural": false, - "selections": [ - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "id", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "completedCount", - "storageKey": null - } - ], - "storageKey": null - } - ], - "storageKey": null - } - ] - }, - "text": "mutation MarkAllTodosMutation(\n $input: MarkAllTodosInput!\n) {\n markAllTodos(input: $input) {\n changedTodos {\n id\n complete\n }\n viewer {\n id\n completedCount\n }\n }\n}\n" -}; - -module.exports = batch; diff --git a/src/GraphQL.Relay.Todo/ClientApp/mutations/__generated__/RemoveCompletedTodosMutation.graphql.js b/src/GraphQL.Relay.Todo/ClientApp/mutations/__generated__/RemoveCompletedTodosMutation.graphql.js deleted file mode 100644 index 44b7e4fa9..000000000 --- a/src/GraphQL.Relay.Todo/ClientApp/mutations/__generated__/RemoveCompletedTodosMutation.graphql.js +++ /dev/null @@ -1,190 +0,0 @@ -/** - * @flow - * @relayHash 05d4aaca3140107c65dfd77d1d390c87 - */ - -/* eslint-disable */ - -'use strict'; - -/*:: -import type {ConcreteBatch} from 'relay-runtime'; -export type RemoveCompletedTodosMutationVariables = {| - input: { - clientMutationId?: ?string; - }; -|}; -export type RemoveCompletedTodosMutationResponse = {| - +removeCompletedTodos: ?{| - +deletedTodoIds: ?$ReadOnlyArray; - +viewer: ?{| - +completedCount: ?number; - +totalCount: ?number; - |}; - |}; -|}; -*/ - - -/* -mutation RemoveCompletedTodosMutation( - $input: RemoveCompletedTodosInput! -) { - removeCompletedTodos(input: $input) { - deletedTodoIds - viewer { - completedCount - totalCount - id - } - } -} -*/ - -const batch /*: ConcreteBatch*/ = { - "fragment": { - "argumentDefinitions": [ - { - "kind": "LocalArgument", - "name": "input", - "type": "RemoveCompletedTodosInput!", - "defaultValue": null - } - ], - "kind": "Fragment", - "metadata": null, - "name": "RemoveCompletedTodosMutation", - "selections": [ - { - "kind": "LinkedField", - "alias": null, - "args": [ - { - "kind": "Variable", - "name": "input", - "variableName": "input", - "type": "RemoveCompletedTodosInput!" - } - ], - "concreteType": "RemoveCompletedTodosPayload", - "name": "removeCompletedTodos", - "plural": false, - "selections": [ - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "deletedTodoIds", - "storageKey": null - }, - { - "kind": "LinkedField", - "alias": null, - "args": null, - "concreteType": "User", - "name": "viewer", - "plural": false, - "selections": [ - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "completedCount", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "totalCount", - "storageKey": null - } - ], - "storageKey": null - } - ], - "storageKey": null - } - ], - "type": "Mutation" - }, - "id": null, - "kind": "Batch", - "metadata": {}, - "name": "RemoveCompletedTodosMutation", - "query": { - "argumentDefinitions": [ - { - "kind": "LocalArgument", - "name": "input", - "type": "RemoveCompletedTodosInput!", - "defaultValue": null - } - ], - "kind": "Root", - "name": "RemoveCompletedTodosMutation", - "operation": "mutation", - "selections": [ - { - "kind": "LinkedField", - "alias": null, - "args": [ - { - "kind": "Variable", - "name": "input", - "variableName": "input", - "type": "RemoveCompletedTodosInput!" - } - ], - "concreteType": "RemoveCompletedTodosPayload", - "name": "removeCompletedTodos", - "plural": false, - "selections": [ - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "deletedTodoIds", - "storageKey": null - }, - { - "kind": "LinkedField", - "alias": null, - "args": null, - "concreteType": "User", - "name": "viewer", - "plural": false, - "selections": [ - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "completedCount", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "totalCount", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "id", - "storageKey": null - } - ], - "storageKey": null - } - ], - "storageKey": null - } - ] - }, - "text": "mutation RemoveCompletedTodosMutation(\n $input: RemoveCompletedTodosInput!\n) {\n removeCompletedTodos(input: $input) {\n deletedTodoIds\n viewer {\n completedCount\n totalCount\n id\n }\n }\n}\n" -}; - -module.exports = batch; diff --git a/src/GraphQL.Relay.Todo/ClientApp/mutations/__generated__/RemoveTodoMutation.graphql.js b/src/GraphQL.Relay.Todo/ClientApp/mutations/__generated__/RemoveTodoMutation.graphql.js deleted file mode 100644 index ee6a18390..000000000 --- a/src/GraphQL.Relay.Todo/ClientApp/mutations/__generated__/RemoveTodoMutation.graphql.js +++ /dev/null @@ -1,191 +0,0 @@ -/** - * @flow - * @relayHash 0a8876b18d239f935cb5ad4f92bf4a8a - */ - -/* eslint-disable */ - -'use strict'; - -/*:: -import type {ConcreteBatch} from 'relay-runtime'; -export type RemoveTodoMutationVariables = {| - input: { - clientMutationId?: ?string; - id?: ?string; - }; -|}; -export type RemoveTodoMutationResponse = {| - +removeTodo: ?{| - +deletedTodoId: ?string; - +viewer: ?{| - +completedCount: ?number; - +totalCount: ?number; - |}; - |}; -|}; -*/ - - -/* -mutation RemoveTodoMutation( - $input: RemoveTodoInput! -) { - removeTodo(input: $input) { - deletedTodoId - viewer { - completedCount - totalCount - id - } - } -} -*/ - -const batch /*: ConcreteBatch*/ = { - "fragment": { - "argumentDefinitions": [ - { - "kind": "LocalArgument", - "name": "input", - "type": "RemoveTodoInput!", - "defaultValue": null - } - ], - "kind": "Fragment", - "metadata": null, - "name": "RemoveTodoMutation", - "selections": [ - { - "kind": "LinkedField", - "alias": null, - "args": [ - { - "kind": "Variable", - "name": "input", - "variableName": "input", - "type": "RemoveTodoInput!" - } - ], - "concreteType": "RemoveTodoPayload", - "name": "removeTodo", - "plural": false, - "selections": [ - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "deletedTodoId", - "storageKey": null - }, - { - "kind": "LinkedField", - "alias": null, - "args": null, - "concreteType": "User", - "name": "viewer", - "plural": false, - "selections": [ - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "completedCount", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "totalCount", - "storageKey": null - } - ], - "storageKey": null - } - ], - "storageKey": null - } - ], - "type": "Mutation" - }, - "id": null, - "kind": "Batch", - "metadata": {}, - "name": "RemoveTodoMutation", - "query": { - "argumentDefinitions": [ - { - "kind": "LocalArgument", - "name": "input", - "type": "RemoveTodoInput!", - "defaultValue": null - } - ], - "kind": "Root", - "name": "RemoveTodoMutation", - "operation": "mutation", - "selections": [ - { - "kind": "LinkedField", - "alias": null, - "args": [ - { - "kind": "Variable", - "name": "input", - "variableName": "input", - "type": "RemoveTodoInput!" - } - ], - "concreteType": "RemoveTodoPayload", - "name": "removeTodo", - "plural": false, - "selections": [ - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "deletedTodoId", - "storageKey": null - }, - { - "kind": "LinkedField", - "alias": null, - "args": null, - "concreteType": "User", - "name": "viewer", - "plural": false, - "selections": [ - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "completedCount", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "totalCount", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "id", - "storageKey": null - } - ], - "storageKey": null - } - ], - "storageKey": null - } - ] - }, - "text": "mutation RemoveTodoMutation(\n $input: RemoveTodoInput!\n) {\n removeTodo(input: $input) {\n deletedTodoId\n viewer {\n completedCount\n totalCount\n id\n }\n }\n}\n" -}; - -module.exports = batch; diff --git a/src/GraphQL.Relay.Todo/ClientApp/mutations/__generated__/RenameTodoMutation.graphql.js b/src/GraphQL.Relay.Todo/ClientApp/mutations/__generated__/RenameTodoMutation.graphql.js deleted file mode 100644 index bbf62aeb7..000000000 --- a/src/GraphQL.Relay.Todo/ClientApp/mutations/__generated__/RenameTodoMutation.graphql.js +++ /dev/null @@ -1,168 +0,0 @@ -/** - * @flow - * @relayHash ca4ce0e6808fa6741913b717f1995ba9 - */ - -/* eslint-disable */ - -'use strict'; - -/*:: -import type {ConcreteBatch} from 'relay-runtime'; -export type RenameTodoMutationVariables = {| - input: { - clientMutationId?: ?string; - id?: ?string; - text?: ?string; - }; -|}; -export type RenameTodoMutationResponse = {| - +renameTodo: ?{| - +todo: ?{| - +id: string; - +text: string; - |}; - |}; -|}; -*/ - - -/* -mutation RenameTodoMutation( - $input: RenameTodoInput! -) { - renameTodo(input: $input) { - todo { - id - text - } - } -} -*/ - -const batch /*: ConcreteBatch*/ = { - "fragment": { - "argumentDefinitions": [ - { - "kind": "LocalArgument", - "name": "input", - "type": "RenameTodoInput!", - "defaultValue": null - } - ], - "kind": "Fragment", - "metadata": null, - "name": "RenameTodoMutation", - "selections": [ - { - "kind": "LinkedField", - "alias": null, - "args": [ - { - "kind": "Variable", - "name": "input", - "variableName": "input", - "type": "RenameTodoInput!" - } - ], - "concreteType": "RenameTodoPayload", - "name": "renameTodo", - "plural": false, - "selections": [ - { - "kind": "LinkedField", - "alias": null, - "args": null, - "concreteType": "Todo", - "name": "todo", - "plural": false, - "selections": [ - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "id", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "text", - "storageKey": null - } - ], - "storageKey": null - } - ], - "storageKey": null - } - ], - "type": "Mutation" - }, - "id": null, - "kind": "Batch", - "metadata": {}, - "name": "RenameTodoMutation", - "query": { - "argumentDefinitions": [ - { - "kind": "LocalArgument", - "name": "input", - "type": "RenameTodoInput!", - "defaultValue": null - } - ], - "kind": "Root", - "name": "RenameTodoMutation", - "operation": "mutation", - "selections": [ - { - "kind": "LinkedField", - "alias": null, - "args": [ - { - "kind": "Variable", - "name": "input", - "variableName": "input", - "type": "RenameTodoInput!" - } - ], - "concreteType": "RenameTodoPayload", - "name": "renameTodo", - "plural": false, - "selections": [ - { - "kind": "LinkedField", - "alias": null, - "args": null, - "concreteType": "Todo", - "name": "todo", - "plural": false, - "selections": [ - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "id", - "storageKey": null - }, - { - "kind": "ScalarField", - "alias": null, - "args": null, - "name": "text", - "storageKey": null - } - ], - "storageKey": null - } - ], - "storageKey": null - } - ] - }, - "text": "mutation RenameTodoMutation(\n $input: RenameTodoInput!\n) {\n renameTodo(input: $input) {\n todo {\n id\n text\n }\n }\n}\n" -}; - -module.exports = batch; diff --git a/src/GraphQL.Relay.Todo/ClientApp/public/index.html b/src/GraphQL.Relay.Todo/ClientApp/public/index.html index 27d0932c7..d14c9820e 100644 --- a/src/GraphQL.Relay.Todo/ClientApp/public/index.html +++ b/src/GraphQL.Relay.Todo/ClientApp/public/index.html @@ -1,6 +1,6 @@  - + @@ -20,11 +20,11 @@ work correctly both with client-side routing and a non-root public URL. Learn how to configure a non-root public URL by running `npm run build`. --> - GraphQL.Relay.Todo - - + Project1 + +
- + diff --git a/src/GraphQL.Relay.Todo/ClientApp/src/App.js b/src/GraphQL.Relay.Todo/ClientApp/src/App.js index a831d8787..eb5dcb61a 100644 --- a/src/GraphQL.Relay.Todo/ClientApp/src/App.js +++ b/src/GraphQL.Relay.Todo/ClientApp/src/App.js @@ -25,7 +25,6 @@ const preloadedQuery = loadQuery(RelayEnvironment, AppQuery, { /* query variables */ }); - function App(props) { const displayName = App.name; const data = usePreloadedQuery(AppQuery, props.preloadedQuery); @@ -35,11 +34,6 @@ function App(props) { ); } -// The above component needs to know how to access the Relay environment, and we -// need to specify a fallback in case it suspends: -// - tells child components how to talk to the current -// Relay Environment instance -// - specifies a fallback in case a child suspends. function AppRoot(props) { return ( diff --git a/src/GraphQL.Relay.Todo/ClientApp/src/__generated__/AppQuery.graphql.js b/src/GraphQL.Relay.Todo/ClientApp/src/__generated__/AppQuery.graphql.js index 56d41fff8..cef26b8c5 100644 --- a/src/GraphQL.Relay.Todo/ClientApp/src/__generated__/AppQuery.graphql.js +++ b/src/GraphQL.Relay.Todo/ClientApp/src/__generated__/AppQuery.graphql.js @@ -33,10 +33,83 @@ query AppQuery { fragment TodoApp_viewer on User { id totalCount + ...TodoListFooter_viewer + ...TodoList_viewer +} + +fragment TodoListFooter_viewer on User { + id + completedCount + completedTodos: todos(status: "completed", first: 2147483647) { + edges { + node { + id + complete + } + } + } + totalCount +} + +fragment TodoList_viewer on User { + todos(first: 2147483647) { + edges { + node { + id + complete + ...Todo_todo + __typename + } + cursor + } + pageInfo { + endCursor + hasNextPage + } + } + id + totalCount + completedCount + ...Todo_viewer +} + +fragment Todo_todo on Todo { + id + complete + text +} + +fragment Todo_viewer on User { + id + totalCount + completedCount } */ -const node/*: ConcreteRequest*/ = { +const node/*: ConcreteRequest*/ = (function(){ +var v0 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "id", + "storageKey": null +}, +v1 = { + "kind": "Literal", + "name": "first", + "value": 2147483647 +}, +v2 = { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "complete", + "storageKey": null +}, +v3 = [ + (v1/*: any*/) +]; +return { "fragment": { "argumentDefinitions": [], "kind": "Fragment", @@ -77,19 +150,152 @@ const node/*: ConcreteRequest*/ = { "name": "viewer", "plural": false, "selections": [ + (v0/*: any*/), { "alias": null, "args": null, "kind": "ScalarField", - "name": "id", + "name": "totalCount", "storageKey": null }, { "alias": null, "args": null, "kind": "ScalarField", - "name": "totalCount", + "name": "completedCount", "storageKey": null + }, + { + "alias": "completedTodos", + "args": [ + (v1/*: any*/), + { + "kind": "Literal", + "name": "status", + "value": "completed" + } + ], + "concreteType": "TodoConnection", + "kind": "LinkedField", + "name": "todos", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "concreteType": "TodoEdge", + "kind": "LinkedField", + "name": "edges", + "plural": true, + "selections": [ + { + "alias": null, + "args": null, + "concreteType": "Todo", + "kind": "LinkedField", + "name": "node", + "plural": false, + "selections": [ + (v0/*: any*/), + (v2/*: any*/) + ], + "storageKey": null + } + ], + "storageKey": null + } + ], + "storageKey": "todos(first:2147483647,status:\"completed\")" + }, + { + "alias": null, + "args": (v3/*: any*/), + "concreteType": "TodoConnection", + "kind": "LinkedField", + "name": "todos", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "concreteType": "TodoEdge", + "kind": "LinkedField", + "name": "edges", + "plural": true, + "selections": [ + { + "alias": null, + "args": null, + "concreteType": "Todo", + "kind": "LinkedField", + "name": "node", + "plural": false, + "selections": [ + (v0/*: any*/), + (v2/*: any*/), + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "text", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "__typename", + "storageKey": null + } + ], + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "cursor", + "storageKey": null + } + ], + "storageKey": null + }, + { + "alias": null, + "args": null, + "concreteType": "PageInfo", + "kind": "LinkedField", + "name": "pageInfo", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "endCursor", + "storageKey": null + }, + { + "alias": null, + "args": null, + "kind": "ScalarField", + "name": "hasNextPage", + "storageKey": null + } + ], + "storageKey": null + } + ], + "storageKey": "todos(first:2147483647)" + }, + { + "alias": null, + "args": (v3/*: any*/), + "filters": null, + "handle": "connection", + "key": "TodoList_todos", + "kind": "LinkedHandle", + "name": "todos" } ], "storageKey": null @@ -97,14 +303,15 @@ const node/*: ConcreteRequest*/ = { ] }, "params": { - "cacheID": "cb5425f6eac2161c3e163b24d1643ab5", + "cacheID": "272a19f7de91069cf483fd7aaca57cdf", "id": null, "metadata": {}, "name": "AppQuery", "operationKind": "query", - "text": "query AppQuery {\n viewer {\n ...TodoApp_viewer\n id\n }\n}\n\nfragment TodoApp_viewer on User {\n id\n totalCount\n}\n" + "text": "query AppQuery {\n viewer {\n ...TodoApp_viewer\n id\n }\n}\n\nfragment TodoApp_viewer on User {\n id\n totalCount\n ...TodoListFooter_viewer\n ...TodoList_viewer\n}\n\nfragment TodoListFooter_viewer on User {\n id\n completedCount\n completedTodos: todos(status: \"completed\", first: 2147483647) {\n edges {\n node {\n id\n complete\n }\n }\n }\n totalCount\n}\n\nfragment TodoList_viewer on User {\n todos(first: 2147483647) {\n edges {\n node {\n id\n complete\n ...Todo_todo\n __typename\n }\n cursor\n }\n pageInfo {\n endCursor\n hasNextPage\n }\n }\n id\n totalCount\n completedCount\n ...Todo_viewer\n}\n\nfragment Todo_todo on Todo {\n id\n complete\n text\n}\n\nfragment Todo_viewer on User {\n id\n totalCount\n completedCount\n}\n" } }; +})(); // prettier-ignore (node/*: any*/).hash = '38cf426fcf85397ae998113b0b1076aa'; diff --git a/src/GraphQL.Relay.Todo/ClientApp/src/components/Header.js b/src/GraphQL.Relay.Todo/ClientApp/src/components/Header.js deleted file mode 100644 index ea93f9bdc..000000000 --- a/src/GraphQL.Relay.Todo/ClientApp/src/components/Header.js +++ /dev/null @@ -1,21 +0,0 @@ -import React from "react"; -import TodoTextInput from "./TodoTextInput"; - -import { addTodo } from "../stores/todo"; - -const Header = () => ( -
-

todos

- { - if (text.length !== 0) { - addTodo(text); - } - }} - placeholder="What needs to be done?" - /> -
-); - -export default Header; diff --git a/src/GraphQL.Relay.Todo/ClientApp/src/components/Link.js b/src/GraphQL.Relay.Todo/ClientApp/src/components/Link.js deleted file mode 100644 index f56f1f82c..000000000 --- a/src/GraphQL.Relay.Todo/ClientApp/src/components/Link.js +++ /dev/null @@ -1,26 +0,0 @@ -import React from "react"; -import PropTypes from "prop-types"; -import classnames from "classnames"; -import { useStore } from "laco-react"; -import { TodoStore, setVisibilityFilter } from "../stores/todo"; - -const Link = ({ children, filter }) => { - const { visibilityFilter } = useStore(TodoStore); - - return ( - setVisibilityFilter(filter)} - > - {children} - - ); -}; - -Link.propTypes = { - children: PropTypes.node.isRequired, - filter: PropTypes.string.isRequired -}; - -export default Link; diff --git a/src/GraphQL.Relay.Todo/ClientApp/src/components/MainSection.js b/src/GraphQL.Relay.Todo/ClientApp/src/components/MainSection.js deleted file mode 100644 index 0a8bb2011..000000000 --- a/src/GraphQL.Relay.Todo/ClientApp/src/components/MainSection.js +++ /dev/null @@ -1,40 +0,0 @@ -import React from "react"; -import Footer from "./TodoListFooter"; -import TodoList from "../components/TodoList"; -import { useStore } from "laco-react"; -import { - TodoStore, - completeAllTodos, - clearCompletedTodos, - getCompletedCount -} from "../stores/todo"; - -const MainSection = () => { - const { todos } = useStore(TodoStore); - const todosCount = todos.length; - const completedCount = getCompletedCount(todos); - return ( -
- {!!todosCount && ( - - - - )} - - {!!todosCount && ( -
- )} -
- ); -}; - -export default MainSection; diff --git a/src/GraphQL.Relay.Todo/ClientApp/components/Todo.js b/src/GraphQL.Relay.Todo/ClientApp/src/components/Todo.js similarity index 100% rename from src/GraphQL.Relay.Todo/ClientApp/components/Todo.js rename to src/GraphQL.Relay.Todo/ClientApp/src/components/Todo.js diff --git a/src/GraphQL.Relay.Todo/ClientApp/src/components/TodoApp.js b/src/GraphQL.Relay.Todo/ClientApp/src/components/TodoApp.js index 2a91fdeb4..c6c1cae1b 100644 --- a/src/GraphQL.Relay.Todo/ClientApp/src/components/TodoApp.js +++ b/src/GraphQL.Relay.Todo/ClientApp/src/components/TodoApp.js @@ -1,87 +1,21 @@ -//import AddTodoMutation from '../mutations/AddTodoMutation'; +import AddTodoMutation from '../mutations/AddTodoMutation'; import TodoList from './TodoList'; import TodoListFooter from './TodoListFooter'; import TodoTextInput from './TodoTextInput'; -import graphql from 'babel-plugin-relay/macro'; import React from 'react'; import { -<<<<<<< Updated upstream:src/GraphQL.Relay.Todo/ClientApp/components/TodoApp.js - createFragmentContainer, - graphql, -} from 'react-relay'; - -class TodoApp extends React.Component { - _handleTextInputSave = (text) => { - AddTodoMutation.commit( - this.props.relay.environment, - text, - this.props.viewer, - ); - }; - render() { - const hasTodos = this.props.viewer.totalCount > 0; - return ( -
-
-
-

- todos -

- -
- - {hasTodos && - - } -
- -
- ); - } -} - -export default createFragmentContainer(TodoApp, { - viewer: graphql` - fragment TodoApp_viewer on User { - id, - totalCount, - ...TodoListFooter_viewer, - ...TodoList_viewer, - } - `, -}); -======= createFragmentContainer, + graphql, } from 'react-relay'; class TodoApp extends React.Component { _handleTextInputSave = (text) => { - //AddTodoMutation.commit( - // this.props.relay.environment, - // text, - // this.props.viewer, - //); + AddTodoMutation.commit( + this.props.relay.environment, + text, + this.props.viewer, + ); }; render() { const hasTodos = this.props.viewer.totalCount > 0; @@ -91,30 +25,30 @@ class TodoApp extends React.Component {

todos -

+
- {/*{hasTodos &&*/} - {/* */} - {/*}*/} + {hasTodos && + + }