├── README.md ├── RelayApp ├── .babelrc ├── .buckconfig ├── .eslintrc ├── .flowconfig ├── .gitignore ├── .nvmrc ├── .watchmanconfig ├── android │ ├── app │ │ ├── BUCK │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── relayapp │ │ │ │ ├── MainActivity.java │ │ │ │ └── MainApplication.java │ │ │ └── res │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── keystores │ │ ├── BUCK │ │ └── debug.keystore.properties │ └── settings.gradle ├── data │ ├── schema.graphql │ └── schema.json ├── index.android.js ├── index.ios.js ├── ios │ ├── RelayApp.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── RelayApp.xcscheme │ ├── RelayApp │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Base.lproj │ │ │ └── LaunchScreen.xib │ │ ├── Images.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── Info.plist │ │ └── main.m │ └── RelayAppTests │ │ ├── Info.plist │ │ └── RelayAppTests.m ├── package.json ├── plugins │ └── babelRelayPlugin.js ├── src │ ├── RelayStore.js │ ├── RelayUtils.js │ ├── ViewerQuery.js │ ├── __tests__ │ │ ├── __snapshots__ │ │ │ └── app.spec.js.snap │ │ └── app.spec.js │ └── app.js ├── test │ └── env.js └── yarn.lock ├── RelayWeb ├── .babelrc ├── .env ├── .eslintrc ├── .gitignore ├── .nvmrc ├── data │ ├── schema.graphql │ └── schema.json ├── package.json ├── plugins │ └── babelRelayPlugin.js ├── src │ ├── RelayStore.js │ ├── RelayUtils.js │ ├── ViewerQuery.js │ ├── __tests__ │ │ ├── __snapshots__ │ │ │ └── app.spec.js.snap │ │ ├── app.spec.js │ │ └── fetch.spec.js │ ├── app.js │ ├── config.js │ ├── index.html │ └── index.js ├── test │ └── env.js ├── webpack.config.js ├── webpack.prod.config.js └── yarn.lock └── server ├── .babelrc ├── .env ├── .env.example ├── .eslintrc ├── .flowconfig ├── .gitignore ├── .nvmrc ├── README.md ├── circle.yml ├── data ├── schema.graphql └── schema.json ├── package.json ├── repl.js ├── repl └── nodemon.json ├── scripts └── updateSchema.js ├── src ├── __tests__ │ └── auth.spec.js ├── app.js ├── auth.js ├── config.js ├── connection │ ├── ConnectionFromMongoCursor.js │ └── UserConnection.js ├── database.js ├── index.js ├── interface │ ├── NodeInterface.js │ └── __tests__ │ │ └── NodeInterface.spec.js ├── loader │ ├── UserLoader.js │ └── ViewerLoader.js ├── models │ ├── User.js │ └── index.js ├── mutation │ ├── ChangePasswordMutation.js │ ├── LoginEmailMutation.js │ ├── RegisterEmail.js │ └── __tests__ │ │ ├── ChangePasswordMutation.spec.js │ │ ├── LoginEmailMutation.spec.js │ │ └── RegisterEmailMutation.spec.js ├── schema.js └── type │ ├── MeType.js │ ├── MutationType.js │ ├── QueryType.js │ ├── UserType.js │ ├── ViewerType.js │ └── __tests__ │ ├── MeType.spec.js │ ├── UserType.spec.js │ └── ViewerType.spec.js ├── test ├── helper.js └── mongooseConnection.js └── yarn.lock /README.md: -------------------------------------------------------------------------------- 1 | # Relay test integration with real GraphQL backend 2 | 3 | ## Summary 4 | This code will test your Relay application against a working GraphQL backend, so we can make sure everything is working (e2e - end to end) 5 | 6 | ## Blog Post 7 | [Relay Integration Test with Jest](https://medium.com/entria/relay-integration-test-with-jest-71236fb36d44#.ghhvvbbvl) 8 | -------------------------------------------------------------------------------- /RelayApp/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "retainLines": true, 3 | "compact": true, 4 | "comments": false, 5 | "presets": [ 6 | "react-native", 7 | ], 8 | "plugins": [ 9 | "./plugins/babelRelayPlugin" 10 | ], 11 | "sourceMaps": false 12 | } 13 | -------------------------------------------------------------------------------- /RelayApp/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /RelayApp/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "babel-eslint", 3 | "env": { 4 | "browser": true, 5 | "node": true, 6 | "jest": true 7 | }, 8 | "plugins": [ 9 | "react", 10 | "react-native", 11 | "flowtype", 12 | "import" 13 | ], 14 | "extends": ["eslint:recommended", "plugin:react/recommended"], 15 | "rules": { 16 | "comma-dangle": [2, "always-multiline"], 17 | "quotes": [2, "single", { "allowTemplateLiterals": true }], 18 | "react/prop-types": 0, 19 | "react/jsx-no-bind": 0, 20 | "react/display-name": 0, 21 | "new-cap": 0, 22 | "react-native/no-unused-styles": 2, 23 | "react-native/split-platform-components": 2, 24 | "react-native/no-inline-styles": 1, 25 | "react-native/no-color-literals": 0, 26 | "no-class-assign": 1, 27 | "no-console": 1, 28 | "object-curly-spacing": [1, "always"], 29 | "flowtype/define-flow-type": 1, 30 | "flowtype/use-flow-type": 1, 31 | "import/first": 2 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /RelayApp/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | # We fork some components by platform. 4 | .*/*[.]android.js 5 | 6 | # Ignore templates with `@flow` in header 7 | .*/local-cli/generator.* 8 | 9 | # Ignore malformed json 10 | .*/node_modules/y18n/test/.*\.json 11 | 12 | # Ignore the website subdir 13 | /website/.* 14 | 15 | # Ignore BUCK generated dirs 16 | /\.buckd/ 17 | 18 | # Ignore unexpected extra @providesModule 19 | .*/node_modules/commoner/test/source/widget/share.js 20 | 21 | # Ignore duplicate module providers 22 | # For RN Apps installed via npm, "Libraries" folder is inside node_modules/react-native but in the source repo it is in the root 23 | .*/Libraries/react-native/React.js 24 | .*/Libraries/react-native/ReactNative.js 25 | .*/node_modules/jest-runtime/build/__tests__/.* 26 | 27 | [include] 28 | 29 | [libs] 30 | node_modules/react-native/Libraries/react-native/react-native-interface.js 31 | node_modules/react-native/flow 32 | flow/ 33 | 34 | [options] 35 | module.system=haste 36 | 37 | esproposal.class_static_fields=enable 38 | esproposal.class_instance_fields=enable 39 | 40 | experimental.strict_type_args=true 41 | 42 | munge_underscores=true 43 | 44 | module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub' 45 | module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' 46 | 47 | suppress_type=$FlowIssue 48 | suppress_type=$FlowFixMe 49 | suppress_type=$FixMe 50 | 51 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-3]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) 52 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-3]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ 53 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy 54 | 55 | unsafe.enable_getters_and_setters=true 56 | 57 | [version] 58 | ^0.33.0 59 | -------------------------------------------------------------------------------- /RelayApp/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # Android/IJ 26 | # 27 | *.iml 28 | .idea 29 | .gradle 30 | local.properties 31 | 32 | # node.js 33 | # 34 | node_modules/ 35 | npm-debug.log 36 | 37 | # BUCK 38 | buck-out/ 39 | \.buckd/ 40 | android/app/libs 41 | android/keystores/debug.keystore 42 | -------------------------------------------------------------------------------- /RelayApp/.nvmrc: -------------------------------------------------------------------------------- 1 | 6.9.1 2 | -------------------------------------------------------------------------------- /RelayApp/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /RelayApp/android/app/BUCK: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | # To learn about Buck see [Docs](https://buckbuild.com/). 4 | # To run your application with Buck: 5 | # - install Buck 6 | # - `npm start` - to start the packager 7 | # - `cd android` 8 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 9 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 10 | # - `buck install -r android/app` - compile, install and run application 11 | # 12 | 13 | lib_deps = [] 14 | for jarfile in glob(['libs/*.jar']): 15 | name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile) 16 | lib_deps.append(':' + name) 17 | prebuilt_jar( 18 | name = name, 19 | binary_jar = jarfile, 20 | ) 21 | 22 | for aarfile in glob(['libs/*.aar']): 23 | name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile) 24 | lib_deps.append(':' + name) 25 | android_prebuilt_aar( 26 | name = name, 27 | aar = aarfile, 28 | ) 29 | 30 | android_library( 31 | name = 'all-libs', 32 | exported_deps = lib_deps 33 | ) 34 | 35 | android_library( 36 | name = 'app-code', 37 | srcs = glob([ 38 | 'src/main/java/**/*.java', 39 | ]), 40 | deps = [ 41 | ':all-libs', 42 | ':build_config', 43 | ':res', 44 | ], 45 | ) 46 | 47 | android_build_config( 48 | name = 'build_config', 49 | package = 'com.relayapp', 50 | ) 51 | 52 | android_resource( 53 | name = 'res', 54 | res = 'src/main/res', 55 | package = 'com.relayapp', 56 | ) 57 | 58 | android_binary( 59 | name = 'app', 60 | package_type = 'debug', 61 | manifest = 'src/main/AndroidManifest.xml', 62 | keystore = '//android/keystores:debug', 63 | deps = [ 64 | ':app-code', 65 | ], 66 | ) 67 | -------------------------------------------------------------------------------- /RelayApp/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | import com.android.build.OutputFile 4 | 5 | /** 6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 7 | * and bundleReleaseJsAndAssets). 8 | * These basically call `react-native bundle` with the correct arguments during the Android build 9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 10 | * bundle directly from the development server. Below you can see all the possible configurations 11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 12 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 13 | * 14 | * project.ext.react = [ 15 | * // the name of the generated asset file containing your JS bundle 16 | * bundleAssetName: "index.android.bundle", 17 | * 18 | * // the entry file for bundle generation 19 | * entryFile: "index.android.js", 20 | * 21 | * // whether to bundle JS and assets in debug mode 22 | * bundleInDebug: false, 23 | * 24 | * // whether to bundle JS and assets in release mode 25 | * bundleInRelease: true, 26 | * 27 | * // whether to bundle JS and assets in another build variant (if configured). 28 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 29 | * // The configuration property can be in the following formats 30 | * // 'bundleIn${productFlavor}${buildType}' 31 | * // 'bundleIn${buildType}' 32 | * // bundleInFreeDebug: true, 33 | * // bundleInPaidRelease: true, 34 | * // bundleInBeta: true, 35 | * 36 | * // the root of your project, i.e. where "package.json" lives 37 | * root: "../../", 38 | * 39 | * // where to put the JS bundle asset in debug mode 40 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 41 | * 42 | * // where to put the JS bundle asset in release mode 43 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 44 | * 45 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 46 | * // require('./image.png')), in debug mode 47 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 48 | * 49 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 50 | * // require('./image.png')), in release mode 51 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 52 | * 53 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 54 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 55 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 56 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 57 | * // for example, you might want to remove it from here. 58 | * inputExcludes: ["android/**", "ios/**"], 59 | * 60 | * // override which node gets called and with what additional arguments 61 | * nodeExecutableAndArgs: ["node"] 62 | * 63 | * // supply additional arguments to the packager 64 | * extraPackagerArgs: [] 65 | * ] 66 | */ 67 | 68 | apply from: "../../node_modules/react-native/react.gradle" 69 | 70 | /** 71 | * Set this to true to create two separate APKs instead of one: 72 | * - An APK that only works on ARM devices 73 | * - An APK that only works on x86 devices 74 | * The advantage is the size of the APK is reduced by about 4MB. 75 | * Upload all the APKs to the Play Store and people will download 76 | * the correct one based on the CPU architecture of their device. 77 | */ 78 | def enableSeparateBuildPerCPUArchitecture = false 79 | 80 | /** 81 | * Run Proguard to shrink the Java bytecode in release builds. 82 | */ 83 | def enableProguardInReleaseBuilds = false 84 | 85 | android { 86 | compileSdkVersion 23 87 | buildToolsVersion "23.0.1" 88 | 89 | defaultConfig { 90 | applicationId "com.relayapp" 91 | minSdkVersion 16 92 | targetSdkVersion 22 93 | versionCode 1 94 | versionName "1.0" 95 | ndk { 96 | abiFilters "armeabi-v7a", "x86" 97 | } 98 | } 99 | splits { 100 | abi { 101 | reset() 102 | enable enableSeparateBuildPerCPUArchitecture 103 | universalApk false // If true, also generate a universal APK 104 | include "armeabi-v7a", "x86" 105 | } 106 | } 107 | buildTypes { 108 | release { 109 | minifyEnabled enableProguardInReleaseBuilds 110 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 111 | } 112 | } 113 | // applicationVariants are e.g. debug, release 114 | applicationVariants.all { variant -> 115 | variant.outputs.each { output -> 116 | // For each separate APK per architecture, set a unique version code as described here: 117 | // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits 118 | def versionCodes = ["armeabi-v7a":1, "x86":2] 119 | def abi = output.getFilter(OutputFile.ABI) 120 | if (abi != null) { // null for the universal-debug, universal-release variants 121 | output.versionCodeOverride = 122 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode 123 | } 124 | } 125 | } 126 | } 127 | 128 | dependencies { 129 | compile fileTree(dir: "libs", include: ["*.jar"]) 130 | compile "com.android.support:appcompat-v7:23.0.1" 131 | compile "com.facebook.react:react-native:+" // From node_modules 132 | } 133 | 134 | // Run this once to be able to run the application with BUCK 135 | // puts all compile dependencies into folder libs for BUCK to use 136 | task copyDownloadableDepsToLibs(type: Copy) { 137 | from configurations.compile 138 | into 'libs' 139 | } 140 | -------------------------------------------------------------------------------- /RelayApp/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Disabling obfuscation is useful if you collect stack traces from production crashes 20 | # (unless you are using a system that supports de-obfuscate the stack traces). 21 | -dontobfuscate 22 | 23 | # React Native 24 | 25 | # Keep our interfaces so they can be used by other ProGuard rules. 26 | # See http://sourceforge.net/p/proguard/bugs/466/ 27 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip 28 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters 29 | -keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip 30 | 31 | # Do not strip any method/class that is annotated with @DoNotStrip 32 | -keep @com.facebook.proguard.annotations.DoNotStrip class * 33 | -keep @com.facebook.common.internal.DoNotStrip class * 34 | -keepclassmembers class * { 35 | @com.facebook.proguard.annotations.DoNotStrip *; 36 | @com.facebook.common.internal.DoNotStrip *; 37 | } 38 | 39 | -keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * { 40 | void set*(***); 41 | *** get*(); 42 | } 43 | 44 | -keep class * extends com.facebook.react.bridge.JavaScriptModule { *; } 45 | -keep class * extends com.facebook.react.bridge.NativeModule { *; } 46 | -keepclassmembers,includedescriptorclasses class * { native ; } 47 | -keepclassmembers class * { @com.facebook.react.uimanager.UIProp ; } 48 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp ; } 49 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup ; } 50 | 51 | -dontwarn com.facebook.react.** 52 | 53 | # okhttp 54 | 55 | -keepattributes Signature 56 | -keepattributes *Annotation* 57 | -keep class okhttp3.** { *; } 58 | -keep interface okhttp3.** { *; } 59 | -dontwarn okhttp3.** 60 | 61 | # okio 62 | 63 | -keep class sun.misc.Unsafe { *; } 64 | -dontwarn java.nio.file.* 65 | -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement 66 | -dontwarn okio.** 67 | -------------------------------------------------------------------------------- /RelayApp/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /RelayApp/android/app/src/main/java/com/relayapp/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.relayapp; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. 9 | * This is used to schedule rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "RelayApp"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /RelayApp/android/app/src/main/java/com/relayapp/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.relayapp; 2 | 3 | import android.app.Application; 4 | import android.util.Log; 5 | 6 | import com.facebook.react.ReactApplication; 7 | import com.facebook.react.ReactInstanceManager; 8 | import com.facebook.react.ReactNativeHost; 9 | import com.facebook.react.ReactPackage; 10 | import com.facebook.react.shell.MainReactPackage; 11 | 12 | import java.util.Arrays; 13 | import java.util.List; 14 | 15 | public class MainApplication extends Application implements ReactApplication { 16 | 17 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 18 | @Override 19 | protected boolean getUseDeveloperSupport() { 20 | return BuildConfig.DEBUG; 21 | } 22 | 23 | @Override 24 | protected List getPackages() { 25 | return Arrays.asList( 26 | new MainReactPackage() 27 | ); 28 | } 29 | }; 30 | 31 | @Override 32 | public ReactNativeHost getReactNativeHost() { 33 | return mReactNativeHost; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /RelayApp/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sibelius/relay-integration-test/5493afbecff528e929275642eab57bd05b5bdad1/RelayApp/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /RelayApp/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sibelius/relay-integration-test/5493afbecff528e929275642eab57bd05b5bdad1/RelayApp/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /RelayApp/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sibelius/relay-integration-test/5493afbecff528e929275642eab57bd05b5bdad1/RelayApp/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /RelayApp/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sibelius/relay-integration-test/5493afbecff528e929275642eab57bd05b5bdad1/RelayApp/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /RelayApp/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | RelayApp 3 | 4 | -------------------------------------------------------------------------------- /RelayApp/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /RelayApp/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:1.3.1' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | mavenLocal() 18 | jcenter() 19 | maven { 20 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 21 | url "$rootDir/../node_modules/react-native/android" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /RelayApp/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.useDeprecatedNdk=true 21 | -------------------------------------------------------------------------------- /RelayApp/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sibelius/relay-integration-test/5493afbecff528e929275642eab57bd05b5bdad1/RelayApp/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /RelayApp/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip 6 | -------------------------------------------------------------------------------- /RelayApp/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /RelayApp/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /RelayApp/android/keystores/BUCK: -------------------------------------------------------------------------------- 1 | keystore( 2 | name = 'debug', 3 | store = 'debug.keystore', 4 | properties = 'debug.keystore.properties', 5 | visibility = [ 6 | 'PUBLIC', 7 | ], 8 | ) 9 | -------------------------------------------------------------------------------- /RelayApp/android/keystores/debug.keystore.properties: -------------------------------------------------------------------------------- 1 | key.store=debug.keystore 2 | key.alias=androiddebugkey 3 | key.store.password=android 4 | key.alias.password=android 5 | -------------------------------------------------------------------------------- /RelayApp/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'RelayApp' 2 | 3 | include ':app' 4 | -------------------------------------------------------------------------------- /RelayApp/data/schema.graphql: -------------------------------------------------------------------------------- 1 | input ChangePasswordInput { 2 | oldPassword: String! 3 | 4 | # user new password 5 | password: String! 6 | clientMutationId: String 7 | } 8 | 9 | type ChangePasswordPayload { 10 | error: String 11 | me: Me 12 | clientMutationId: String 13 | } 14 | 15 | input LoginEmailInput { 16 | email: String! 17 | password: String! 18 | clientMutationId: String 19 | } 20 | 21 | type LoginEmailPayload { 22 | token: String 23 | error: String 24 | clientMutationId: String 25 | } 26 | 27 | # Object with data related and only available to the logged user 28 | type Me implements Node { 29 | # The ID of an object 30 | id: ID! 31 | _id: String 32 | name: String 33 | email: String 34 | active: Boolean 35 | } 36 | 37 | type Mutation { 38 | LoginEmail(input: LoginEmailInput!): LoginEmailPayload 39 | RegisterEmail(input: RegisterEmailInput!): RegisterEmailPayload 40 | ChangePassword(input: ChangePasswordInput!): ChangePasswordPayload 41 | } 42 | 43 | # An object with an ID 44 | interface Node { 45 | # The id of the object. 46 | id: ID! 47 | } 48 | 49 | # Information about pagination in a connection. 50 | type PageInfo { 51 | # When paginating forwards, are there more items? 52 | hasNextPage: Boolean! 53 | 54 | # When paginating backwards, are there more items? 55 | hasPreviousPage: Boolean! 56 | 57 | # When paginating backwards, the cursor to continue. 58 | startCursor: String 59 | 60 | # When paginating forwards, the cursor to continue. 61 | endCursor: String 62 | } 63 | 64 | # The root of all... queries 65 | type Query { 66 | # Fetches an object given its ID 67 | node( 68 | # The ID of an object 69 | id: ID! 70 | ): Node 71 | viewer: Viewer 72 | } 73 | 74 | input RegisterEmailInput { 75 | name: String! 76 | email: String! 77 | password: String! 78 | clientMutationId: String 79 | } 80 | 81 | type RegisterEmailPayload { 82 | token: String 83 | error: String 84 | clientMutationId: String 85 | } 86 | 87 | # User data 88 | type User implements Node { 89 | # The ID of an object 90 | id: ID! 91 | _id: String 92 | name: String 93 | email: String 94 | active: Boolean 95 | } 96 | 97 | # A connection to a list of items. 98 | type UserConnection { 99 | # Information to aid in pagination. 100 | pageInfo: PageInfo! 101 | 102 | # A list of edges. 103 | edges: [UserEdge] 104 | count: Int 105 | } 106 | 107 | # An edge in a connection. 108 | type UserEdge { 109 | # The item at the end of the edge 110 | node: User 111 | 112 | # A cursor for use in pagination 113 | cursor: String! 114 | } 115 | 116 | # ... 117 | type Viewer implements Node { 118 | # The ID of an object 119 | id: ID! 120 | me: Me 121 | user(id: ID!): User 122 | users(after: String, first: Int, before: String, last: Int, search: String): UserConnection 123 | } 124 | -------------------------------------------------------------------------------- /RelayApp/index.android.js: -------------------------------------------------------------------------------- 1 | import { AppRegistry }from 'react-native'; 2 | import App from './src/app'; 3 | 4 | AppRegistry.registerComponent('RelayApp', () => App); 5 | -------------------------------------------------------------------------------- /RelayApp/index.ios.js: -------------------------------------------------------------------------------- 1 | import { AppRegistry }from 'react-native'; 2 | import App from './src/app'; 3 | 4 | AppRegistry.registerComponent('RelayApp', () => App); 5 | -------------------------------------------------------------------------------- /RelayApp/ios/RelayApp.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; }; 11 | 00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; }; 12 | 00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */; }; 13 | 00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */; }; 14 | 00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */; }; 15 | 00E356F31AD99517003FC87E /* RelayAppTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* RelayAppTests.m */; }; 16 | 133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 78C398B91ACF4ADC00677621 /* libRCTLinking.a */; }; 17 | 139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */; }; 18 | 139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */; }; 19 | 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; }; 20 | 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; }; 21 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 22 | 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; 23 | 140ED2AC1D01E1AD002B40FF /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; }; 24 | 146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; }; 25 | 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; }; 26 | /* End PBXBuildFile section */ 27 | 28 | /* Begin PBXContainerItemProxy section */ 29 | 00C302AB1ABCB8CE00DB3ED1 /* PBXContainerItemProxy */ = { 30 | isa = PBXContainerItemProxy; 31 | containerPortal = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */; 32 | proxyType = 2; 33 | remoteGlobalIDString = 134814201AA4EA6300B7C361; 34 | remoteInfo = RCTActionSheet; 35 | }; 36 | 00C302B91ABCB90400DB3ED1 /* PBXContainerItemProxy */ = { 37 | isa = PBXContainerItemProxy; 38 | containerPortal = 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */; 39 | proxyType = 2; 40 | remoteGlobalIDString = 134814201AA4EA6300B7C361; 41 | remoteInfo = RCTGeolocation; 42 | }; 43 | 00C302BF1ABCB91800DB3ED1 /* PBXContainerItemProxy */ = { 44 | isa = PBXContainerItemProxy; 45 | containerPortal = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */; 46 | proxyType = 2; 47 | remoteGlobalIDString = 58B5115D1A9E6B3D00147676; 48 | remoteInfo = RCTImage; 49 | }; 50 | 00C302DB1ABCB9D200DB3ED1 /* PBXContainerItemProxy */ = { 51 | isa = PBXContainerItemProxy; 52 | containerPortal = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */; 53 | proxyType = 2; 54 | remoteGlobalIDString = 58B511DB1A9E6C8500147676; 55 | remoteInfo = RCTNetwork; 56 | }; 57 | 00C302E31ABCB9EE00DB3ED1 /* PBXContainerItemProxy */ = { 58 | isa = PBXContainerItemProxy; 59 | containerPortal = 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */; 60 | proxyType = 2; 61 | remoteGlobalIDString = 832C81801AAF6DEF007FA2F7; 62 | remoteInfo = RCTVibration; 63 | }; 64 | 00E356F41AD99517003FC87E /* PBXContainerItemProxy */ = { 65 | isa = PBXContainerItemProxy; 66 | containerPortal = 83CBB9F71A601CBA00E9B192 /* Project object */; 67 | proxyType = 1; 68 | remoteGlobalIDString = 13B07F861A680F5B00A75B9A; 69 | remoteInfo = RelayApp; 70 | }; 71 | 139105C01AF99BAD00B5F7CC /* PBXContainerItemProxy */ = { 72 | isa = PBXContainerItemProxy; 73 | containerPortal = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */; 74 | proxyType = 2; 75 | remoteGlobalIDString = 134814201AA4EA6300B7C361; 76 | remoteInfo = RCTSettings; 77 | }; 78 | 139FDEF31B06529B00C62182 /* PBXContainerItemProxy */ = { 79 | isa = PBXContainerItemProxy; 80 | containerPortal = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */; 81 | proxyType = 2; 82 | remoteGlobalIDString = 3C86DF461ADF2C930047B81A; 83 | remoteInfo = RCTWebSocket; 84 | }; 85 | 146834031AC3E56700842450 /* PBXContainerItemProxy */ = { 86 | isa = PBXContainerItemProxy; 87 | containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; 88 | proxyType = 2; 89 | remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192; 90 | remoteInfo = React; 91 | }; 92 | 78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */ = { 93 | isa = PBXContainerItemProxy; 94 | containerPortal = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */; 95 | proxyType = 2; 96 | remoteGlobalIDString = 134814201AA4EA6300B7C361; 97 | remoteInfo = RCTLinking; 98 | }; 99 | 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */ = { 100 | isa = PBXContainerItemProxy; 101 | containerPortal = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */; 102 | proxyType = 2; 103 | remoteGlobalIDString = 58B5119B1A9E6C1200147676; 104 | remoteInfo = RCTText; 105 | }; 106 | /* End PBXContainerItemProxy section */ 107 | 108 | /* Begin PBXFileReference section */ 109 | 008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = main.jsbundle; path = main.jsbundle; sourceTree = ""; }; 110 | 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTActionSheet.xcodeproj; path = ../node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj; sourceTree = ""; }; 111 | 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTGeolocation.xcodeproj; path = ../node_modules/react-native/Libraries/Geolocation/RCTGeolocation.xcodeproj; sourceTree = ""; }; 112 | 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTImage.xcodeproj; path = ../node_modules/react-native/Libraries/Image/RCTImage.xcodeproj; sourceTree = ""; }; 113 | 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetwork.xcodeproj; path = ../node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj; sourceTree = ""; }; 114 | 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTVibration.xcodeproj; path = ../node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj; sourceTree = ""; }; 115 | 00E356EE1AD99517003FC87E /* RelayAppTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RelayAppTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 116 | 00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 117 | 00E356F21AD99517003FC87E /* RelayAppTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RelayAppTests.m; sourceTree = ""; }; 118 | 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = ../node_modules/react-native/Libraries/Settings/RCTSettings.xcodeproj; sourceTree = ""; }; 119 | 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTWebSocket.xcodeproj; path = ../node_modules/react-native/Libraries/WebSocket/RCTWebSocket.xcodeproj; sourceTree = ""; }; 120 | 13B07F961A680F5B00A75B9A /* RelayApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RelayApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 121 | 13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = RelayApp/AppDelegate.h; sourceTree = ""; }; 122 | 13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = RelayApp/AppDelegate.m; sourceTree = ""; }; 123 | 13B07FB21A68108700A75B9A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 124 | 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = RelayApp/Images.xcassets; sourceTree = ""; }; 125 | 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = RelayApp/Info.plist; sourceTree = ""; }; 126 | 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = RelayApp/main.m; sourceTree = ""; }; 127 | 146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = ../node_modules/react-native/React/React.xcodeproj; sourceTree = ""; }; 128 | 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = ../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj; sourceTree = ""; }; 129 | 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = ../node_modules/react-native/Libraries/Text/RCTText.xcodeproj; sourceTree = ""; }; 130 | /* End PBXFileReference section */ 131 | 132 | /* Begin PBXFrameworksBuildPhase section */ 133 | 00E356EB1AD99517003FC87E /* Frameworks */ = { 134 | isa = PBXFrameworksBuildPhase; 135 | buildActionMask = 2147483647; 136 | files = ( 137 | 140ED2AC1D01E1AD002B40FF /* libReact.a in Frameworks */, 138 | ); 139 | runOnlyForDeploymentPostprocessing = 0; 140 | }; 141 | 13B07F8C1A680F5B00A75B9A /* Frameworks */ = { 142 | isa = PBXFrameworksBuildPhase; 143 | buildActionMask = 2147483647; 144 | files = ( 145 | 146834051AC3E58100842450 /* libReact.a in Frameworks */, 146 | 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */, 147 | 00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */, 148 | 00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */, 149 | 133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */, 150 | 00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */, 151 | 139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */, 152 | 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */, 153 | 00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */, 154 | 139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */, 155 | ); 156 | runOnlyForDeploymentPostprocessing = 0; 157 | }; 158 | /* End PBXFrameworksBuildPhase section */ 159 | 160 | /* Begin PBXGroup section */ 161 | 00C302A81ABCB8CE00DB3ED1 /* Products */ = { 162 | isa = PBXGroup; 163 | children = ( 164 | 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */, 165 | ); 166 | name = Products; 167 | sourceTree = ""; 168 | }; 169 | 00C302B61ABCB90400DB3ED1 /* Products */ = { 170 | isa = PBXGroup; 171 | children = ( 172 | 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */, 173 | ); 174 | name = Products; 175 | sourceTree = ""; 176 | }; 177 | 00C302BC1ABCB91800DB3ED1 /* Products */ = { 178 | isa = PBXGroup; 179 | children = ( 180 | 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */, 181 | ); 182 | name = Products; 183 | sourceTree = ""; 184 | }; 185 | 00C302D41ABCB9D200DB3ED1 /* Products */ = { 186 | isa = PBXGroup; 187 | children = ( 188 | 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */, 189 | ); 190 | name = Products; 191 | sourceTree = ""; 192 | }; 193 | 00C302E01ABCB9EE00DB3ED1 /* Products */ = { 194 | isa = PBXGroup; 195 | children = ( 196 | 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */, 197 | ); 198 | name = Products; 199 | sourceTree = ""; 200 | }; 201 | 00E356EF1AD99517003FC87E /* RelayAppTests */ = { 202 | isa = PBXGroup; 203 | children = ( 204 | 00E356F21AD99517003FC87E /* RelayAppTests.m */, 205 | 00E356F01AD99517003FC87E /* Supporting Files */, 206 | ); 207 | path = RelayAppTests; 208 | sourceTree = ""; 209 | }; 210 | 00E356F01AD99517003FC87E /* Supporting Files */ = { 211 | isa = PBXGroup; 212 | children = ( 213 | 00E356F11AD99517003FC87E /* Info.plist */, 214 | ); 215 | name = "Supporting Files"; 216 | sourceTree = ""; 217 | }; 218 | 139105B71AF99BAD00B5F7CC /* Products */ = { 219 | isa = PBXGroup; 220 | children = ( 221 | 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */, 222 | ); 223 | name = Products; 224 | sourceTree = ""; 225 | }; 226 | 139FDEE71B06529A00C62182 /* Products */ = { 227 | isa = PBXGroup; 228 | children = ( 229 | 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */, 230 | ); 231 | name = Products; 232 | sourceTree = ""; 233 | }; 234 | 13B07FAE1A68108700A75B9A /* RelayApp */ = { 235 | isa = PBXGroup; 236 | children = ( 237 | 008F07F21AC5B25A0029DE68 /* main.jsbundle */, 238 | 13B07FAF1A68108700A75B9A /* AppDelegate.h */, 239 | 13B07FB01A68108700A75B9A /* AppDelegate.m */, 240 | 13B07FB51A68108700A75B9A /* Images.xcassets */, 241 | 13B07FB61A68108700A75B9A /* Info.plist */, 242 | 13B07FB11A68108700A75B9A /* LaunchScreen.xib */, 243 | 13B07FB71A68108700A75B9A /* main.m */, 244 | ); 245 | name = RelayApp; 246 | sourceTree = ""; 247 | }; 248 | 146834001AC3E56700842450 /* Products */ = { 249 | isa = PBXGroup; 250 | children = ( 251 | 146834041AC3E56700842450 /* libReact.a */, 252 | ); 253 | name = Products; 254 | sourceTree = ""; 255 | }; 256 | 78C398B11ACF4ADC00677621 /* Products */ = { 257 | isa = PBXGroup; 258 | children = ( 259 | 78C398B91ACF4ADC00677621 /* libRCTLinking.a */, 260 | ); 261 | name = Products; 262 | sourceTree = ""; 263 | }; 264 | 832341AE1AAA6A7D00B99B32 /* Libraries */ = { 265 | isa = PBXGroup; 266 | children = ( 267 | 146833FF1AC3E56700842450 /* React.xcodeproj */, 268 | 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */, 269 | 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */, 270 | 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */, 271 | 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */, 272 | 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */, 273 | 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */, 274 | 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */, 275 | 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */, 276 | 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */, 277 | ); 278 | name = Libraries; 279 | sourceTree = ""; 280 | }; 281 | 832341B11AAA6A8300B99B32 /* Products */ = { 282 | isa = PBXGroup; 283 | children = ( 284 | 832341B51AAA6A8300B99B32 /* libRCTText.a */, 285 | ); 286 | name = Products; 287 | sourceTree = ""; 288 | }; 289 | 83CBB9F61A601CBA00E9B192 = { 290 | isa = PBXGroup; 291 | children = ( 292 | 13B07FAE1A68108700A75B9A /* RelayApp */, 293 | 832341AE1AAA6A7D00B99B32 /* Libraries */, 294 | 00E356EF1AD99517003FC87E /* RelayAppTests */, 295 | 83CBBA001A601CBA00E9B192 /* Products */, 296 | ); 297 | indentWidth = 2; 298 | sourceTree = ""; 299 | tabWidth = 2; 300 | }; 301 | 83CBBA001A601CBA00E9B192 /* Products */ = { 302 | isa = PBXGroup; 303 | children = ( 304 | 13B07F961A680F5B00A75B9A /* RelayApp.app */, 305 | 00E356EE1AD99517003FC87E /* RelayAppTests.xctest */, 306 | ); 307 | name = Products; 308 | sourceTree = ""; 309 | }; 310 | /* End PBXGroup section */ 311 | 312 | /* Begin PBXNativeTarget section */ 313 | 00E356ED1AD99517003FC87E /* RelayAppTests */ = { 314 | isa = PBXNativeTarget; 315 | buildConfigurationList = 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "RelayAppTests" */; 316 | buildPhases = ( 317 | 00E356EA1AD99517003FC87E /* Sources */, 318 | 00E356EB1AD99517003FC87E /* Frameworks */, 319 | 00E356EC1AD99517003FC87E /* Resources */, 320 | ); 321 | buildRules = ( 322 | ); 323 | dependencies = ( 324 | 00E356F51AD99517003FC87E /* PBXTargetDependency */, 325 | ); 326 | name = RelayAppTests; 327 | productName = RelayAppTests; 328 | productReference = 00E356EE1AD99517003FC87E /* RelayAppTests.xctest */; 329 | productType = "com.apple.product-type.bundle.unit-test"; 330 | }; 331 | 13B07F861A680F5B00A75B9A /* RelayApp */ = { 332 | isa = PBXNativeTarget; 333 | buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "RelayApp" */; 334 | buildPhases = ( 335 | 13B07F871A680F5B00A75B9A /* Sources */, 336 | 13B07F8C1A680F5B00A75B9A /* Frameworks */, 337 | 13B07F8E1A680F5B00A75B9A /* Resources */, 338 | 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */, 339 | ); 340 | buildRules = ( 341 | ); 342 | dependencies = ( 343 | ); 344 | name = RelayApp; 345 | productName = "Hello World"; 346 | productReference = 13B07F961A680F5B00A75B9A /* RelayApp.app */; 347 | productType = "com.apple.product-type.application"; 348 | }; 349 | /* End PBXNativeTarget section */ 350 | 351 | /* Begin PBXProject section */ 352 | 83CBB9F71A601CBA00E9B192 /* Project object */ = { 353 | isa = PBXProject; 354 | attributes = { 355 | LastUpgradeCheck = 0610; 356 | ORGANIZATIONNAME = Facebook; 357 | TargetAttributes = { 358 | 00E356ED1AD99517003FC87E = { 359 | CreatedOnToolsVersion = 6.2; 360 | TestTargetID = 13B07F861A680F5B00A75B9A; 361 | }; 362 | }; 363 | }; 364 | buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "RelayApp" */; 365 | compatibilityVersion = "Xcode 3.2"; 366 | developmentRegion = English; 367 | hasScannedForEncodings = 0; 368 | knownRegions = ( 369 | en, 370 | Base, 371 | ); 372 | mainGroup = 83CBB9F61A601CBA00E9B192; 373 | productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */; 374 | projectDirPath = ""; 375 | projectReferences = ( 376 | { 377 | ProductGroup = 00C302A81ABCB8CE00DB3ED1 /* Products */; 378 | ProjectRef = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */; 379 | }, 380 | { 381 | ProductGroup = 00C302B61ABCB90400DB3ED1 /* Products */; 382 | ProjectRef = 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */; 383 | }, 384 | { 385 | ProductGroup = 00C302BC1ABCB91800DB3ED1 /* Products */; 386 | ProjectRef = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */; 387 | }, 388 | { 389 | ProductGroup = 78C398B11ACF4ADC00677621 /* Products */; 390 | ProjectRef = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */; 391 | }, 392 | { 393 | ProductGroup = 00C302D41ABCB9D200DB3ED1 /* Products */; 394 | ProjectRef = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */; 395 | }, 396 | { 397 | ProductGroup = 139105B71AF99BAD00B5F7CC /* Products */; 398 | ProjectRef = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */; 399 | }, 400 | { 401 | ProductGroup = 832341B11AAA6A8300B99B32 /* Products */; 402 | ProjectRef = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */; 403 | }, 404 | { 405 | ProductGroup = 00C302E01ABCB9EE00DB3ED1 /* Products */; 406 | ProjectRef = 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */; 407 | }, 408 | { 409 | ProductGroup = 139FDEE71B06529A00C62182 /* Products */; 410 | ProjectRef = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */; 411 | }, 412 | { 413 | ProductGroup = 146834001AC3E56700842450 /* Products */; 414 | ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */; 415 | }, 416 | ); 417 | projectRoot = ""; 418 | targets = ( 419 | 13B07F861A680F5B00A75B9A /* RelayApp */, 420 | 00E356ED1AD99517003FC87E /* RelayAppTests */, 421 | ); 422 | }; 423 | /* End PBXProject section */ 424 | 425 | /* Begin PBXReferenceProxy section */ 426 | 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */ = { 427 | isa = PBXReferenceProxy; 428 | fileType = archive.ar; 429 | path = libRCTActionSheet.a; 430 | remoteRef = 00C302AB1ABCB8CE00DB3ED1 /* PBXContainerItemProxy */; 431 | sourceTree = BUILT_PRODUCTS_DIR; 432 | }; 433 | 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */ = { 434 | isa = PBXReferenceProxy; 435 | fileType = archive.ar; 436 | path = libRCTGeolocation.a; 437 | remoteRef = 00C302B91ABCB90400DB3ED1 /* PBXContainerItemProxy */; 438 | sourceTree = BUILT_PRODUCTS_DIR; 439 | }; 440 | 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */ = { 441 | isa = PBXReferenceProxy; 442 | fileType = archive.ar; 443 | path = libRCTImage.a; 444 | remoteRef = 00C302BF1ABCB91800DB3ED1 /* PBXContainerItemProxy */; 445 | sourceTree = BUILT_PRODUCTS_DIR; 446 | }; 447 | 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */ = { 448 | isa = PBXReferenceProxy; 449 | fileType = archive.ar; 450 | path = libRCTNetwork.a; 451 | remoteRef = 00C302DB1ABCB9D200DB3ED1 /* PBXContainerItemProxy */; 452 | sourceTree = BUILT_PRODUCTS_DIR; 453 | }; 454 | 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */ = { 455 | isa = PBXReferenceProxy; 456 | fileType = archive.ar; 457 | path = libRCTVibration.a; 458 | remoteRef = 00C302E31ABCB9EE00DB3ED1 /* PBXContainerItemProxy */; 459 | sourceTree = BUILT_PRODUCTS_DIR; 460 | }; 461 | 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */ = { 462 | isa = PBXReferenceProxy; 463 | fileType = archive.ar; 464 | path = libRCTSettings.a; 465 | remoteRef = 139105C01AF99BAD00B5F7CC /* PBXContainerItemProxy */; 466 | sourceTree = BUILT_PRODUCTS_DIR; 467 | }; 468 | 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */ = { 469 | isa = PBXReferenceProxy; 470 | fileType = archive.ar; 471 | path = libRCTWebSocket.a; 472 | remoteRef = 139FDEF31B06529B00C62182 /* PBXContainerItemProxy */; 473 | sourceTree = BUILT_PRODUCTS_DIR; 474 | }; 475 | 146834041AC3E56700842450 /* libReact.a */ = { 476 | isa = PBXReferenceProxy; 477 | fileType = archive.ar; 478 | path = libReact.a; 479 | remoteRef = 146834031AC3E56700842450 /* PBXContainerItemProxy */; 480 | sourceTree = BUILT_PRODUCTS_DIR; 481 | }; 482 | 78C398B91ACF4ADC00677621 /* libRCTLinking.a */ = { 483 | isa = PBXReferenceProxy; 484 | fileType = archive.ar; 485 | path = libRCTLinking.a; 486 | remoteRef = 78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */; 487 | sourceTree = BUILT_PRODUCTS_DIR; 488 | }; 489 | 832341B51AAA6A8300B99B32 /* libRCTText.a */ = { 490 | isa = PBXReferenceProxy; 491 | fileType = archive.ar; 492 | path = libRCTText.a; 493 | remoteRef = 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */; 494 | sourceTree = BUILT_PRODUCTS_DIR; 495 | }; 496 | /* End PBXReferenceProxy section */ 497 | 498 | /* Begin PBXResourcesBuildPhase section */ 499 | 00E356EC1AD99517003FC87E /* Resources */ = { 500 | isa = PBXResourcesBuildPhase; 501 | buildActionMask = 2147483647; 502 | files = ( 503 | ); 504 | runOnlyForDeploymentPostprocessing = 0; 505 | }; 506 | 13B07F8E1A680F5B00A75B9A /* Resources */ = { 507 | isa = PBXResourcesBuildPhase; 508 | buildActionMask = 2147483647; 509 | files = ( 510 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, 511 | 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */, 512 | ); 513 | runOnlyForDeploymentPostprocessing = 0; 514 | }; 515 | /* End PBXResourcesBuildPhase section */ 516 | 517 | /* Begin PBXShellScriptBuildPhase section */ 518 | 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = { 519 | isa = PBXShellScriptBuildPhase; 520 | buildActionMask = 2147483647; 521 | files = ( 522 | ); 523 | inputPaths = ( 524 | ); 525 | name = "Bundle React Native code and images"; 526 | outputPaths = ( 527 | ); 528 | runOnlyForDeploymentPostprocessing = 0; 529 | shellPath = /bin/sh; 530 | shellScript = "export NODE_BINARY=node\n../node_modules/react-native/packager/react-native-xcode.sh"; 531 | showEnvVarsInLog = 1; 532 | }; 533 | /* End PBXShellScriptBuildPhase section */ 534 | 535 | /* Begin PBXSourcesBuildPhase section */ 536 | 00E356EA1AD99517003FC87E /* Sources */ = { 537 | isa = PBXSourcesBuildPhase; 538 | buildActionMask = 2147483647; 539 | files = ( 540 | 00E356F31AD99517003FC87E /* RelayAppTests.m in Sources */, 541 | ); 542 | runOnlyForDeploymentPostprocessing = 0; 543 | }; 544 | 13B07F871A680F5B00A75B9A /* Sources */ = { 545 | isa = PBXSourcesBuildPhase; 546 | buildActionMask = 2147483647; 547 | files = ( 548 | 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */, 549 | 13B07FC11A68108700A75B9A /* main.m in Sources */, 550 | ); 551 | runOnlyForDeploymentPostprocessing = 0; 552 | }; 553 | /* End PBXSourcesBuildPhase section */ 554 | 555 | /* Begin PBXTargetDependency section */ 556 | 00E356F51AD99517003FC87E /* PBXTargetDependency */ = { 557 | isa = PBXTargetDependency; 558 | target = 13B07F861A680F5B00A75B9A /* RelayApp */; 559 | targetProxy = 00E356F41AD99517003FC87E /* PBXContainerItemProxy */; 560 | }; 561 | /* End PBXTargetDependency section */ 562 | 563 | /* Begin PBXVariantGroup section */ 564 | 13B07FB11A68108700A75B9A /* LaunchScreen.xib */ = { 565 | isa = PBXVariantGroup; 566 | children = ( 567 | 13B07FB21A68108700A75B9A /* Base */, 568 | ); 569 | name = LaunchScreen.xib; 570 | path = RelayApp; 571 | sourceTree = ""; 572 | }; 573 | /* End PBXVariantGroup section */ 574 | 575 | /* Begin XCBuildConfiguration section */ 576 | 00E356F61AD99517003FC87E /* Debug */ = { 577 | isa = XCBuildConfiguration; 578 | buildSettings = { 579 | BUNDLE_LOADER = "$(TEST_HOST)"; 580 | GCC_PREPROCESSOR_DEFINITIONS = ( 581 | "DEBUG=1", 582 | "$(inherited)", 583 | ); 584 | INFOPLIST_FILE = RelayAppTests/Info.plist; 585 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 586 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 587 | PRODUCT_NAME = "$(TARGET_NAME)"; 588 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/RelayApp.app/RelayApp"; 589 | }; 590 | name = Debug; 591 | }; 592 | 00E356F71AD99517003FC87E /* Release */ = { 593 | isa = XCBuildConfiguration; 594 | buildSettings = { 595 | BUNDLE_LOADER = "$(TEST_HOST)"; 596 | COPY_PHASE_STRIP = NO; 597 | INFOPLIST_FILE = RelayAppTests/Info.plist; 598 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 599 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 600 | PRODUCT_NAME = "$(TARGET_NAME)"; 601 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/RelayApp.app/RelayApp"; 602 | }; 603 | name = Release; 604 | }; 605 | 13B07F941A680F5B00A75B9A /* Debug */ = { 606 | isa = XCBuildConfiguration; 607 | buildSettings = { 608 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 609 | CURRENT_PROJECT_VERSION = 1; 610 | DEAD_CODE_STRIPPING = NO; 611 | HEADER_SEARCH_PATHS = ( 612 | "$(inherited)", 613 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 614 | "$(SRCROOT)/../node_modules/react-native/React/**", 615 | ); 616 | INFOPLIST_FILE = "RelayApp/Info.plist"; 617 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 618 | OTHER_LDFLAGS = ( 619 | "$(inherited)", 620 | "-ObjC", 621 | "-lc++", 622 | ); 623 | PRODUCT_NAME = RelayApp; 624 | VERSIONING_SYSTEM = "apple-generic"; 625 | }; 626 | name = Debug; 627 | }; 628 | 13B07F951A680F5B00A75B9A /* Release */ = { 629 | isa = XCBuildConfiguration; 630 | buildSettings = { 631 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 632 | CURRENT_PROJECT_VERSION = 1; 633 | HEADER_SEARCH_PATHS = ( 634 | "$(inherited)", 635 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 636 | "$(SRCROOT)/../node_modules/react-native/React/**", 637 | ); 638 | INFOPLIST_FILE = "RelayApp/Info.plist"; 639 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 640 | OTHER_LDFLAGS = ( 641 | "$(inherited)", 642 | "-ObjC", 643 | "-lc++", 644 | ); 645 | PRODUCT_NAME = RelayApp; 646 | VERSIONING_SYSTEM = "apple-generic"; 647 | }; 648 | name = Release; 649 | }; 650 | 83CBBA201A601CBA00E9B192 /* Debug */ = { 651 | isa = XCBuildConfiguration; 652 | buildSettings = { 653 | ALWAYS_SEARCH_USER_PATHS = NO; 654 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 655 | CLANG_CXX_LIBRARY = "libc++"; 656 | CLANG_ENABLE_MODULES = YES; 657 | CLANG_ENABLE_OBJC_ARC = YES; 658 | CLANG_WARN_BOOL_CONVERSION = YES; 659 | CLANG_WARN_CONSTANT_CONVERSION = YES; 660 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 661 | CLANG_WARN_EMPTY_BODY = YES; 662 | CLANG_WARN_ENUM_CONVERSION = YES; 663 | CLANG_WARN_INT_CONVERSION = YES; 664 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 665 | CLANG_WARN_UNREACHABLE_CODE = YES; 666 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 667 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 668 | COPY_PHASE_STRIP = NO; 669 | ENABLE_STRICT_OBJC_MSGSEND = YES; 670 | GCC_C_LANGUAGE_STANDARD = gnu99; 671 | GCC_DYNAMIC_NO_PIC = NO; 672 | GCC_OPTIMIZATION_LEVEL = 0; 673 | GCC_PREPROCESSOR_DEFINITIONS = ( 674 | "DEBUG=1", 675 | "$(inherited)", 676 | ); 677 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 678 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 679 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 680 | GCC_WARN_UNDECLARED_SELECTOR = YES; 681 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 682 | GCC_WARN_UNUSED_FUNCTION = YES; 683 | GCC_WARN_UNUSED_VARIABLE = YES; 684 | HEADER_SEARCH_PATHS = ( 685 | "$(inherited)", 686 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 687 | "$(SRCROOT)/../node_modules/react-native/React/**", 688 | ); 689 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 690 | MTL_ENABLE_DEBUG_INFO = YES; 691 | ONLY_ACTIVE_ARCH = YES; 692 | SDKROOT = iphoneos; 693 | }; 694 | name = Debug; 695 | }; 696 | 83CBBA211A601CBA00E9B192 /* Release */ = { 697 | isa = XCBuildConfiguration; 698 | buildSettings = { 699 | ALWAYS_SEARCH_USER_PATHS = NO; 700 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 701 | CLANG_CXX_LIBRARY = "libc++"; 702 | CLANG_ENABLE_MODULES = YES; 703 | CLANG_ENABLE_OBJC_ARC = YES; 704 | CLANG_WARN_BOOL_CONVERSION = YES; 705 | CLANG_WARN_CONSTANT_CONVERSION = YES; 706 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 707 | CLANG_WARN_EMPTY_BODY = YES; 708 | CLANG_WARN_ENUM_CONVERSION = YES; 709 | CLANG_WARN_INT_CONVERSION = YES; 710 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 711 | CLANG_WARN_UNREACHABLE_CODE = YES; 712 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 713 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 714 | COPY_PHASE_STRIP = YES; 715 | ENABLE_NS_ASSERTIONS = NO; 716 | ENABLE_STRICT_OBJC_MSGSEND = YES; 717 | GCC_C_LANGUAGE_STANDARD = gnu99; 718 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 719 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 720 | GCC_WARN_UNDECLARED_SELECTOR = YES; 721 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 722 | GCC_WARN_UNUSED_FUNCTION = YES; 723 | GCC_WARN_UNUSED_VARIABLE = YES; 724 | HEADER_SEARCH_PATHS = ( 725 | "$(inherited)", 726 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 727 | "$(SRCROOT)/../node_modules/react-native/React/**", 728 | ); 729 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 730 | MTL_ENABLE_DEBUG_INFO = NO; 731 | SDKROOT = iphoneos; 732 | VALIDATE_PRODUCT = YES; 733 | }; 734 | name = Release; 735 | }; 736 | /* End XCBuildConfiguration section */ 737 | 738 | /* Begin XCConfigurationList section */ 739 | 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "RelayAppTests" */ = { 740 | isa = XCConfigurationList; 741 | buildConfigurations = ( 742 | 00E356F61AD99517003FC87E /* Debug */, 743 | 00E356F71AD99517003FC87E /* Release */, 744 | ); 745 | defaultConfigurationIsVisible = 0; 746 | defaultConfigurationName = Release; 747 | }; 748 | 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "RelayApp" */ = { 749 | isa = XCConfigurationList; 750 | buildConfigurations = ( 751 | 13B07F941A680F5B00A75B9A /* Debug */, 752 | 13B07F951A680F5B00A75B9A /* Release */, 753 | ); 754 | defaultConfigurationIsVisible = 0; 755 | defaultConfigurationName = Release; 756 | }; 757 | 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "RelayApp" */ = { 758 | isa = XCConfigurationList; 759 | buildConfigurations = ( 760 | 83CBBA201A601CBA00E9B192 /* Debug */, 761 | 83CBBA211A601CBA00E9B192 /* Release */, 762 | ); 763 | defaultConfigurationIsVisible = 0; 764 | defaultConfigurationName = Release; 765 | }; 766 | /* End XCConfigurationList section */ 767 | }; 768 | rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */; 769 | } 770 | -------------------------------------------------------------------------------- /RelayApp/ios/RelayApp.xcodeproj/xcshareddata/xcschemes/RelayApp.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 77 | 83 | 84 | 85 | 86 | 87 | 88 | 94 | 96 | 102 | 103 | 104 | 105 | 107 | 108 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /RelayApp/ios/RelayApp/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | @interface AppDelegate : UIResponder 13 | 14 | @property (nonatomic, strong) UIWindow *window; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /RelayApp/ios/RelayApp/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "AppDelegate.h" 11 | 12 | #import "RCTBundleURLProvider.h" 13 | #import "RCTRootView.h" 14 | 15 | @implementation AppDelegate 16 | 17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 18 | { 19 | NSURL *jsCodeLocation; 20 | 21 | jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil]; 22 | 23 | RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation 24 | moduleName:@"RelayApp" 25 | initialProperties:nil 26 | launchOptions:launchOptions]; 27 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 28 | 29 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 30 | UIViewController *rootViewController = [UIViewController new]; 31 | rootViewController.view = rootView; 32 | self.window.rootViewController = rootViewController; 33 | [self.window makeKeyAndVisible]; 34 | return YES; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /RelayApp/ios/RelayApp/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /RelayApp/ios/RelayApp/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /RelayApp/ios/RelayApp/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UIViewControllerBasedStatusBarAppearance 38 | 39 | NSLocationWhenInUseUsageDescription 40 | 41 | NSAppTransportSecurity 42 | 43 | 44 | NSExceptionDomains 45 | 46 | localhost 47 | 48 | NSExceptionAllowsInsecureHTTPLoads 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /RelayApp/ios/RelayApp/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | #import "AppDelegate.h" 13 | 14 | int main(int argc, char * argv[]) { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /RelayApp/ios/RelayAppTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /RelayApp/ios/RelayAppTests/RelayAppTests.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | #import 12 | 13 | #import "RCTLog.h" 14 | #import "RCTRootView.h" 15 | 16 | #define TIMEOUT_SECONDS 600 17 | #define TEXT_TO_LOOK_FOR @"Welcome to React Native!" 18 | 19 | @interface RelayAppTests : XCTestCase 20 | 21 | @end 22 | 23 | @implementation RelayAppTests 24 | 25 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 26 | { 27 | if (test(view)) { 28 | return YES; 29 | } 30 | for (UIView *subview in [view subviews]) { 31 | if ([self findSubviewInView:subview matching:test]) { 32 | return YES; 33 | } 34 | } 35 | return NO; 36 | } 37 | 38 | - (void)testRendersWelcomeScreen 39 | { 40 | UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; 41 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 42 | BOOL foundElement = NO; 43 | 44 | __block NSString *redboxError = nil; 45 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 46 | if (level >= RCTLogLevelError) { 47 | redboxError = message; 48 | } 49 | }); 50 | 51 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 52 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 53 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 54 | 55 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 56 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 57 | return YES; 58 | } 59 | return NO; 60 | }]; 61 | } 62 | 63 | RCTSetLogFunction(RCTDefaultLogFunction); 64 | 65 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 66 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 67 | } 68 | 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /RelayApp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "RelayApp", 3 | "version": "0.0.1", 4 | "dependencies": { 5 | "react": "~15.3.1", 6 | "react-native": "0.37.0", 7 | "react-relay": "^0.9.3" 8 | }, 9 | "devDependencies": { 10 | "babel-jest": "17.0.0", 11 | "babel-preset-react-native": "1.9.0", 12 | "babel-relay-plugin": "^0.9.3", 13 | "jest": "17.0.0", 14 | "jest-react-native": "17.0.0", 15 | "react-test-renderer": "~15.3.1", 16 | "xhr2": "^0.1.3" 17 | }, 18 | "jest": { 19 | "preset": "jest-react-native", 20 | "setupFiles": [ 21 | "./test/env.js" 22 | ] 23 | }, 24 | "private": true, 25 | "scripts": { 26 | "lint": "eslint src", 27 | "start": "node node_modules/react-native/local-cli/cli.js start", 28 | "clear": "node node_modules/react-native/local-cli/cli.js start --reset-cache", 29 | "test": "jest" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /RelayApp/plugins/babelRelayPlugin.js: -------------------------------------------------------------------------------- 1 | const getBabelRelayPlugin = require('babel-relay-plugin'); 2 | 3 | const schemaData = require('../data/schema.json'); 4 | 5 | module.exports = getBabelRelayPlugin(schemaData.data); 6 | -------------------------------------------------------------------------------- /RelayApp/src/RelayStore.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import { Environment } from 'react-relay'; 4 | // import invariant from 'invariant'; 5 | 6 | // eslint-disable-next-line no-unused-vars 7 | import RelayNetworkDebug from 'react-relay/lib/RelayNetworkDebug'; 8 | 9 | class RelayStore { 10 | constructor() { 11 | this._env = new Environment(); 12 | this._networkLayer = null; 13 | this._taskScheduler = null; 14 | 15 | RelayNetworkDebug.init(this._env); 16 | } 17 | 18 | reset(networkLayer) { 19 | // invariant( 20 | // !this._env.getStoreData().getChangeEmitter().hasActiveListeners() && 21 | // !this._env.getStoreData().getMutationQueue().hasPendingMutations() && 22 | // !this._env.getStoreData().getPendingQueryTracker().hasPendingQueries(), 23 | // 'RelayStore.reset(): Cannot reset the store while there are active ' + 24 | // 'Relay Containers or pending mutations/queries.' 25 | // ); 26 | 27 | // console.log('reset networkLayer: ', networkLayer); 28 | 29 | if (networkLayer !== undefined) { 30 | this._networkLayer = networkLayer; 31 | } 32 | 33 | this._env = new Environment(); 34 | if (this._networkLayer !== null) { 35 | this._env.injectNetworkLayer(this._networkLayer); 36 | } 37 | if (this._taskScheduler !== null) { 38 | this._env.injectTaskScheduler(this._taskScheduler); 39 | } 40 | 41 | // Comment/Uncomment the line bellow to enable relay debug (dafult commented) 42 | RelayNetworkDebug.init(this._env); 43 | } 44 | 45 | // Map existing RelayEnvironment methods 46 | getStoreData() { 47 | return this._env.getStoreData(); 48 | } 49 | 50 | injectNetworkLayer(networkLayer) { 51 | this._networkLayer = networkLayer; 52 | this._env.injectNetworkLayer(networkLayer); 53 | } 54 | 55 | injectTaskScheduler(taskScheduler) { 56 | this._taskScheduler = taskScheduler; 57 | this._env.injectTaskScheduler(taskScheduler); 58 | } 59 | 60 | primeCache(...args) { 61 | return this._env.primeCache(...args); 62 | } 63 | 64 | forceFetch(...args) { 65 | return this._env.forceFetch(...args); 66 | } 67 | 68 | read(...args) { 69 | return this._env.read(...args); 70 | } 71 | 72 | readAll(...args) { 73 | return this._env.readAll(...args); 74 | } 75 | 76 | readQuery(...args) { 77 | return this._env.readQuery(...args); 78 | } 79 | 80 | observe(...args) { 81 | return this._env.observe(...args); 82 | } 83 | 84 | getFragmentResolver(...args) { 85 | return this._env.getFragmentResolver(...args); 86 | } 87 | 88 | applyUpdate(...args) { 89 | return this._env.applyUpdate(...args); 90 | } 91 | 92 | commitUpdate(...args) { 93 | return this._env.commitUpdate(...args); 94 | } 95 | 96 | /** 97 | * @deprecated 98 | * 99 | * Method renamed to commitUpdate 100 | */ 101 | update(...args) { 102 | return this._env.update(...args); 103 | } 104 | } 105 | 106 | const relayStore = new RelayStore(); 107 | 108 | export default relayStore; 109 | -------------------------------------------------------------------------------- /RelayApp/src/RelayUtils.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | // reference code: https://gist.github.com/janicduplessis/f513032eb37cdde5d050d9ce8cf0b92a 3 | 4 | import React from 'react'; 5 | import type { Element as ReactElement } from 'react'; 6 | import { 7 | ActivityIndicator, 8 | View, 9 | StyleSheet, 10 | Text, 11 | TouchableOpacity, 12 | } from 'react-native'; 13 | import Relay from 'react-relay'; 14 | import RelayStore from './RelayStore'; 15 | 16 | type Variables = {[name: string]: mixed}; 17 | 18 | type Config = { 19 | queries: {[name: string]: any}; 20 | queriesParams?: ?(props: Object) => Object; 21 | fragments: {[name: string]: any}; 22 | initialVariables?: Variables; 23 | prepareVariables?: (prevVariables: Variables, route: any) => Variables; 24 | forceFetch?: bool; 25 | onReadyStateChange?: (readyState: any) => void; 26 | renderFetched?: ( 27 | props: Object, 28 | fetchState: { done: bool; stale: bool } 29 | ) => ?ReactElement; 30 | renderLoading?: () => ?ReactElement; 31 | renderFailure?: (error: Error, retry: ?() => void) => ?ReactElement; 32 | }; 33 | 34 | const styles = StyleSheet.create({ 35 | content: { 36 | flex: 1, 37 | alignItems: 'stretch', 38 | backgroundColor: '#cfcfcf', 39 | }, 40 | loading: { 41 | flex: 1, 42 | alignItems: 'center', 43 | justifyContent: 'center', 44 | backgroundColor: 'lightgray', 45 | }, 46 | }); 47 | 48 | const LoadingView = () => ( 49 | 50 | 51 | 52 | 53 | 54 | ); 55 | 56 | const FailureView = ({ error, retry }) => ( 57 | 58 | Error 59 | {error.message} 60 | 61 | Try again 62 | 63 | 64 | ); 65 | 66 | export function createRenderer( 67 | Component: ReactClass<*>, 68 | config: Config 69 | ): ReactClass<*> { 70 | return createRendererInternal(Component, { 71 | forceFetch: false, 72 | renderLoading: () => , 73 | renderFailure: (error, retry) => , 74 | ...config, 75 | }); 76 | } 77 | 78 | function createRendererInternal( 79 | Component: ReactClass<*>, 80 | config: Config 81 | ): ReactClass<*> { 82 | const { 83 | queries, 84 | queriesParams, 85 | forceFetch, 86 | renderFetched, 87 | renderLoading, 88 | renderFailure, 89 | onReadyStateChange, 90 | fragments, 91 | initialVariables, 92 | prepareVariables, 93 | } = config; 94 | 95 | const RelayComponent = Relay.createContainer(Component, { 96 | fragments, 97 | initialVariables, 98 | prepareVariables, 99 | }); 100 | 101 | class RelayRendererWrapper extends React.Component { 102 | state = { 103 | queryConfig: this._computeQueryConfig(this.props), 104 | }; 105 | 106 | render() { 107 | return ( 108 | { 115 | console.log('renderer: ', done, error, props, stale); 116 | 117 | if (error) { 118 | if (renderFailure) { 119 | return renderFailure(error, retry); 120 | } 121 | } else if (props) { 122 | if (renderFetched) { 123 | return renderFetched({ ...this.props, ...props }, { done, stale }); 124 | } else { 125 | return ; 126 | } 127 | } else if (renderLoading) { 128 | return renderLoading(); 129 | } 130 | return undefined; 131 | }} 132 | /> 133 | ); 134 | } 135 | 136 | componentWillReceiveProps(nextProps: Object) { 137 | if (this.props.routeParams !== nextProps.routeParams) { 138 | this.setState({ 139 | queryConfig: this._computeQueryConfig(nextProps), 140 | }); 141 | } 142 | } 143 | 144 | _computeQueryConfig(props: Object) { 145 | const params = queriesParams ? queriesParams(props) : {}; 146 | 147 | // remove parenthesis ( ) 148 | const name = `relay_route_${RelayComponent.displayName}`.replace(/[\(|\)]/g, '_'); 149 | 150 | const queryConfig = { 151 | name, 152 | queries: { ...queries }, 153 | params, 154 | }; 155 | 156 | return queryConfig; 157 | } 158 | } 159 | 160 | if (Component.route) { 161 | RelayRendererWrapper.route = Component.route; 162 | } 163 | 164 | return RelayRendererWrapper; 165 | } 166 | -------------------------------------------------------------------------------- /RelayApp/src/ViewerQuery.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | import Relay from 'react-relay'; 3 | 4 | const ViewerQuery = { 5 | viewer: () => Relay.QL` 6 | query { 7 | viewer 8 | } 9 | `, 10 | }; 11 | 12 | export default ViewerQuery; 13 | -------------------------------------------------------------------------------- /RelayApp/src/__tests__/__snapshots__/app.spec.js.snap: -------------------------------------------------------------------------------- 1 | exports[`test renders correctly 1`] = ` 2 | 3 | 7 | name: 8 | Awesome 9 | 10 | 14 | length: 15 | 1 16 | 17 | 18 | `; 19 | -------------------------------------------------------------------------------- /RelayApp/src/__tests__/app.spec.js: -------------------------------------------------------------------------------- 1 | import 'react-native'; 2 | import React from 'react'; 3 | import Relay from 'react-relay'; 4 | import App from '../app'; 5 | import RelayStore from '../RelayStore'; 6 | 7 | // Note: test renderer must be required after react-native. 8 | import renderer from 'react-test-renderer'; 9 | 10 | RelayStore.reset( 11 | new Relay.DefaultNetworkLayer('http://localhost:5000/graphql') 12 | ); 13 | 14 | const delay = (value) => new Promise(resolve => setTimeout(() => resolve(), value)); 15 | 16 | it('renders correctly', async () => { 17 | const tree = renderer.create( 18 | 19 | ); 20 | 21 | await delay(3000); 22 | 23 | expect(tree.toJSON()).toMatchSnapshot(); 24 | }); 25 | -------------------------------------------------------------------------------- /RelayApp/src/app.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { 3 | StyleSheet, 4 | Text, 5 | View, 6 | } from 'react-native'; 7 | import Relay from 'react-relay'; 8 | import ViewerQuery from './ViewerQuery'; 9 | import { createRenderer } from './RelayUtils'; 10 | import RelayStore from './RelayStore'; 11 | 12 | RelayStore.reset( 13 | new Relay.DefaultNetworkLayer('http://localhost:5000/graphql') 14 | ); 15 | 16 | class RelayApp extends Component { 17 | render() { 18 | console.log('RelayApp: ', this.props); 19 | return ( 20 | 21 | name: {this.props.viewer.users.edges[0].node.name} 22 | length: {this.props.viewer.users.edges.length} 23 | 24 | ); 25 | } 26 | } 27 | 28 | // Create a Relay.Renderer container 29 | export default createRenderer(RelayApp, { 30 | queries: ViewerQuery, 31 | fragments: { 32 | viewer: () => Relay.QL` 33 | fragment on Viewer { 34 | users(first: 2) { 35 | edges { 36 | node { 37 | name 38 | } 39 | } 40 | } 41 | } 42 | `, 43 | }, 44 | }); 45 | -------------------------------------------------------------------------------- /RelayApp/test/env.js: -------------------------------------------------------------------------------- 1 | const XMLHttpRequest = require('xhr2'); 2 | 3 | global.XMLHttpRequest = XMLHttpRequest; 4 | 5 | 6 | -------------------------------------------------------------------------------- /RelayWeb/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "passPerPreset": true, 3 | "presets": [ 4 | { 5 | "plugins": [ 6 | "./plugins/babelRelayPlugin" 7 | ] 8 | }, 9 | "react", 10 | "es2015", 11 | "stage-0" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /RelayWeb/.env: -------------------------------------------------------------------------------- 1 | GRAPHQL_URL=http://localhost:5000/graphql 2 | -------------------------------------------------------------------------------- /RelayWeb/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "ecmaFeatures": { 3 | "jsx": true, 4 | "modules": true 5 | }, 6 | "env": { 7 | "browser": true, 8 | "node": true 9 | }, 10 | "parser": "babel-eslint", 11 | "rules": { 12 | "quotes": [2, "single"], 13 | "strict": [2, "never"], 14 | "react/jsx-uses-react": 2, 15 | "react/jsx-uses-vars": 2, 16 | "react/react-in-jsx-scope": 2, 17 | "react/jsx-no-undef": 1, // Disallow use of undefined components 18 | "react/no-direct-mutation-state": 1, // Prevent direct mutation of state 19 | "no-undef": 1, // Disallow use of undefined variables 20 | "no-var": 1, // Require the use of let or const instead of var (ES6) 21 | }, 22 | "plugins": [ 23 | "react" 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /RelayWeb/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | npm-debug.log 3 | .DS_Store 4 | dist 5 | admin 6 | console 7 | .idea 8 | graphql.*.json 9 | -------------------------------------------------------------------------------- /RelayWeb/.nvmrc: -------------------------------------------------------------------------------- 1 | 6.9.1 2 | -------------------------------------------------------------------------------- /RelayWeb/data/schema.graphql: -------------------------------------------------------------------------------- 1 | input ChangePasswordInput { 2 | oldPassword: String! 3 | 4 | # user new password 5 | password: String! 6 | clientMutationId: String 7 | } 8 | 9 | type ChangePasswordPayload { 10 | error: String 11 | me: Me 12 | clientMutationId: String 13 | } 14 | 15 | input LoginEmailInput { 16 | email: String! 17 | password: String! 18 | clientMutationId: String 19 | } 20 | 21 | type LoginEmailPayload { 22 | token: String 23 | error: String 24 | clientMutationId: String 25 | } 26 | 27 | # Object with data related and only available to the logged user 28 | type Me implements Node { 29 | # The ID of an object 30 | id: ID! 31 | _id: String 32 | name: String 33 | email: String 34 | active: Boolean 35 | } 36 | 37 | type Mutation { 38 | LoginEmail(input: LoginEmailInput!): LoginEmailPayload 39 | RegisterEmail(input: RegisterEmailInput!): RegisterEmailPayload 40 | ChangePassword(input: ChangePasswordInput!): ChangePasswordPayload 41 | } 42 | 43 | # An object with an ID 44 | interface Node { 45 | # The id of the object. 46 | id: ID! 47 | } 48 | 49 | # Information about pagination in a connection. 50 | type PageInfo { 51 | # When paginating forwards, are there more items? 52 | hasNextPage: Boolean! 53 | 54 | # When paginating backwards, are there more items? 55 | hasPreviousPage: Boolean! 56 | 57 | # When paginating backwards, the cursor to continue. 58 | startCursor: String 59 | 60 | # When paginating forwards, the cursor to continue. 61 | endCursor: String 62 | } 63 | 64 | # The root of all... queries 65 | type Query { 66 | # Fetches an object given its ID 67 | node( 68 | # The ID of an object 69 | id: ID! 70 | ): Node 71 | viewer: Viewer 72 | } 73 | 74 | input RegisterEmailInput { 75 | name: String! 76 | email: String! 77 | password: String! 78 | clientMutationId: String 79 | } 80 | 81 | type RegisterEmailPayload { 82 | token: String 83 | error: String 84 | clientMutationId: String 85 | } 86 | 87 | # User data 88 | type User implements Node { 89 | # The ID of an object 90 | id: ID! 91 | _id: String 92 | name: String 93 | email: String 94 | active: Boolean 95 | } 96 | 97 | # A connection to a list of items. 98 | type UserConnection { 99 | # Information to aid in pagination. 100 | pageInfo: PageInfo! 101 | 102 | # A list of edges. 103 | edges: [UserEdge] 104 | count: Int 105 | } 106 | 107 | # An edge in a connection. 108 | type UserEdge { 109 | # The item at the end of the edge 110 | node: User 111 | 112 | # A cursor for use in pagination 113 | cursor: String! 114 | } 115 | 116 | # ... 117 | type Viewer implements Node { 118 | # The ID of an object 119 | id: ID! 120 | me: Me 121 | user(id: ID!): User 122 | users(after: String, first: Int, before: String, last: Int, search: String): UserConnection 123 | } 124 | -------------------------------------------------------------------------------- /RelayWeb/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "relay-web-integration-test", 3 | "description": "Relay Web testing integration test", 4 | "version": "1.0.0", 5 | "author": "Sibelius Seraphini", 6 | "dependencies": { 7 | "babel-relay-plugin": "^0.9.3", 8 | "lodash": "^4.16.1", 9 | "moment": "2.15.1", 10 | "react": "15.3.2", 11 | "react-dom": "15.3.2", 12 | "react-relay": "^0.9.3", 13 | "react-router": "2.8.1", 14 | "react-router-relay": "^0.13.5", 15 | "react-test-renderer": "^15.4.0" 16 | }, 17 | "devDependencies": { 18 | "babel-core": "6.17.0", 19 | "babel-eslint": "7.0.0", 20 | "babel-loader": "6.2.5", 21 | "babel-polyfill": "6.16.0", 22 | "babel-preset-es2015": "6.16.0", 23 | "babel-preset-react": "6.16.0", 24 | "babel-preset-stage-0": "6.16.0", 25 | "babel-register": "6.16.3", 26 | "chai": "3.5.0", 27 | "clean-webpack-plugin": "0.1.11", 28 | "dotenv-webpack": "1.0.1", 29 | "enzyme": "2.4.1", 30 | "eslint": "3.7.1", 31 | "eslint-plugin-react": "6.3.0", 32 | "html-webpack-plugin": "2.22.0", 33 | "jest": "^17.0.3", 34 | "jest-cli": "^17.0.3", 35 | "jsdom": "9.6.0", 36 | "mocha": "3.1.0", 37 | "react-addons-test-utils": "15.3.2", 38 | "react-hot-loader": "3.0.0-beta.5", 39 | "webpack": "1.13.2", 40 | "webpack-dev-server": "1.16.2" 41 | }, 42 | "jest": { 43 | "setupFiles": [ 44 | "./test/env.js" 45 | ] 46 | }, 47 | "scripts": { 48 | "build": "npm run build:prod", 49 | "build:dev": "NODE_ENV=development webpack --production --config webpack.prod.config.js --progress --profile --colors", 50 | "build:prod": "NODE_ENV=production webpack --production --config webpack.prod.config.js --progress --profile --colors", 51 | "lint": "eslint --ext js src || exit 0", 52 | "start": "webpack-dev-server --config webpack.config.js --progress --profile --colors", 53 | "test": "jest" 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /RelayWeb/plugins/babelRelayPlugin.js: -------------------------------------------------------------------------------- 1 | const getBabelRelayPlugin = require('babel-relay-plugin'); 2 | 3 | const schemaData = require('../data/schema.json'); 4 | 5 | module.exports = getBabelRelayPlugin(schemaData.data); 6 | -------------------------------------------------------------------------------- /RelayWeb/src/RelayStore.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import { Environment } from 'react-relay'; 4 | // import invariant from 'invariant'; 5 | 6 | // eslint-disable-next-line no-unused-vars 7 | import RelayNetworkDebug from 'react-relay/lib/RelayNetworkDebug'; 8 | 9 | class RelayStore { 10 | constructor() { 11 | this._env = new Environment(); 12 | this._networkLayer = null; 13 | this._taskScheduler = null; 14 | 15 | RelayNetworkDebug.init(this._env); 16 | } 17 | 18 | reset(networkLayer) { 19 | // invariant( 20 | // !this._env.getStoreData().getChangeEmitter().hasActiveListeners() && 21 | // !this._env.getStoreData().getMutationQueue().hasPendingMutations() && 22 | // !this._env.getStoreData().getPendingQueryTracker().hasPendingQueries(), 23 | // 'RelayStore.reset(): Cannot reset the store while there are active ' + 24 | // 'Relay Containers or pending mutations/queries.' 25 | // ); 26 | 27 | // console.log('reset networkLayer: ', networkLayer); 28 | 29 | if (networkLayer !== undefined) { 30 | this._networkLayer = networkLayer; 31 | } 32 | 33 | this._env = new Environment(); 34 | if (this._networkLayer !== null) { 35 | this._env.injectNetworkLayer(this._networkLayer); 36 | } 37 | if (this._taskScheduler !== null) { 38 | this._env.injectTaskScheduler(this._taskScheduler); 39 | } 40 | 41 | // Comment/Uncomment the line bellow to enable relay debug (dafult commented) 42 | RelayNetworkDebug.init(this._env); 43 | } 44 | 45 | // Map existing RelayEnvironment methods 46 | getStoreData() { 47 | return this._env.getStoreData(); 48 | } 49 | 50 | injectNetworkLayer(networkLayer) { 51 | this._networkLayer = networkLayer; 52 | this._env.injectNetworkLayer(networkLayer); 53 | } 54 | 55 | injectTaskScheduler(taskScheduler) { 56 | this._taskScheduler = taskScheduler; 57 | this._env.injectTaskScheduler(taskScheduler); 58 | } 59 | 60 | primeCache(...args) { 61 | return this._env.primeCache(...args); 62 | } 63 | 64 | forceFetch(...args) { 65 | return this._env.forceFetch(...args); 66 | } 67 | 68 | read(...args) { 69 | return this._env.read(...args); 70 | } 71 | 72 | readAll(...args) { 73 | return this._env.readAll(...args); 74 | } 75 | 76 | readQuery(...args) { 77 | return this._env.readQuery(...args); 78 | } 79 | 80 | observe(...args) { 81 | return this._env.observe(...args); 82 | } 83 | 84 | getFragmentResolver(...args) { 85 | return this._env.getFragmentResolver(...args); 86 | } 87 | 88 | applyUpdate(...args) { 89 | return this._env.applyUpdate(...args); 90 | } 91 | 92 | commitUpdate(...args) { 93 | return this._env.commitUpdate(...args); 94 | } 95 | 96 | /** 97 | * @deprecated 98 | * 99 | * Method renamed to commitUpdate 100 | */ 101 | update(...args) { 102 | return this._env.update(...args); 103 | } 104 | } 105 | 106 | const relayStore = new RelayStore(); 107 | 108 | export default relayStore; 109 | -------------------------------------------------------------------------------- /RelayWeb/src/RelayUtils.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | // reference code: https://gist.github.com/janicduplessis/f513032eb37cdde5d050d9ce8cf0b92a 3 | 4 | import React from 'react'; 5 | import type { Element as ReactElement } from 'react'; 6 | import Relay from 'react-relay'; 7 | import RelayStore from './RelayStore'; 8 | 9 | type Variables = {[name: string]: mixed}; 10 | 11 | type Config = { 12 | queries: {[name: string]: any}; 13 | queriesParams?: ?(props: Object) => Object; 14 | fragments: {[name: string]: any}; 15 | initialVariables?: Variables; 16 | prepareVariables?: (prevVariables: Variables, route: any) => Variables; 17 | forceFetch?: bool; 18 | onReadyStateChange?: (readyState: any) => void; 19 | renderFetched?: ( 20 | props: Object, 21 | fetchState: { done: bool; stale: bool } 22 | ) => ?ReactElement; 23 | renderLoading?: () => ?ReactElement; 24 | renderFailure?: (error: Error, retry: ?() => void) => ?ReactElement; 25 | }; 26 | 27 | const styles = { 28 | content: { 29 | flex: 1, 30 | alignItems: 'stretch', 31 | backgroundColor: '#cfcfcf', 32 | }, 33 | loading: { 34 | flex: 1, 35 | alignItems: 'center', 36 | justifyContent: 'center', 37 | backgroundColor: 'lightgray', 38 | }, 39 | }; 40 | 41 | const LoadingView = () => ( 42 |
43 |
44 | Loading 45 |
46 |
47 | ); 48 | 49 | const FailureView = ({ error, retry }) => ( 50 |
51 | Error 52 | {error.message} 53 | 56 |
57 | ); 58 | 59 | export function createRenderer( 60 | Component: ReactClass<*>, 61 | config: Config 62 | ): ReactClass<*> { 63 | return createRendererInternal(Component, { 64 | forceFetch: false, 65 | renderLoading: () => , 66 | renderFailure: (error, retry) => , 67 | ...config, 68 | }); 69 | } 70 | 71 | function createRendererInternal( 72 | Component: ReactClass<*>, 73 | config: Config 74 | ): ReactClass<*> { 75 | const { 76 | queries, 77 | queriesParams, 78 | forceFetch, 79 | renderFetched, 80 | renderLoading, 81 | renderFailure, 82 | onReadyStateChange, 83 | fragments, 84 | initialVariables, 85 | prepareVariables, 86 | } = config; 87 | 88 | const RelayComponent = Relay.createContainer(Component, { 89 | fragments, 90 | initialVariables, 91 | prepareVariables, 92 | }); 93 | 94 | class RelayRendererWrapper extends React.Component { 95 | state = { 96 | queryConfig: this._computeQueryConfig(this.props), 97 | }; 98 | 99 | render() { 100 | return ( 101 | { 108 | console.log('renderer: ', done, error, props, stale); 109 | 110 | if (error) { 111 | if (renderFailure) { 112 | return renderFailure(error, retry); 113 | } 114 | } else if (props) { 115 | if (renderFetched) { 116 | return renderFetched({ ...this.props, ...props }, { done, stale }); 117 | } else { 118 | return ; 119 | } 120 | } else if (renderLoading) { 121 | return renderLoading(); 122 | } 123 | return undefined; 124 | }} 125 | /> 126 | ); 127 | } 128 | 129 | componentWillReceiveProps(nextProps: Object) { 130 | if (this.props.routeParams !== nextProps.routeParams) { 131 | this.setState({ 132 | queryConfig: this._computeQueryConfig(nextProps), 133 | }); 134 | } 135 | } 136 | 137 | _computeQueryConfig(props: Object) { 138 | const params = queriesParams ? queriesParams(props) : {}; 139 | 140 | // remove parenthesis ( ) 141 | const name = `relay_route_${RelayComponent.displayName}`.replace(/[\(|\)]/g, '_'); 142 | 143 | const queryConfig = { 144 | name, 145 | queries: { ...queries }, 146 | params, 147 | }; 148 | 149 | return queryConfig; 150 | } 151 | } 152 | 153 | if (Component.route) { 154 | RelayRendererWrapper.route = Component.route; 155 | } 156 | 157 | return RelayRendererWrapper; 158 | } 159 | -------------------------------------------------------------------------------- /RelayWeb/src/ViewerQuery.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | import Relay from 'react-relay'; 3 | 4 | const ViewerQuery = { 5 | viewer: () => Relay.QL` 6 | query { 7 | viewer 8 | } 9 | `, 10 | }; 11 | 12 | export default ViewerQuery; 13 | -------------------------------------------------------------------------------- /RelayWeb/src/__tests__/__snapshots__/app.spec.js.snap: -------------------------------------------------------------------------------- 1 | exports[`test renders correctly 1`] = ` 2 |
10 |
19 | 20 | Loading 21 | 22 |
23 |
24 | `; 25 | -------------------------------------------------------------------------------- /RelayWeb/src/__tests__/app.spec.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Relay from 'react-relay'; 3 | import App from '../app'; 4 | import RelayStore from '../RelayStore'; 5 | 6 | // Note: test renderer must be required after react-native. 7 | import renderer from 'react-test-renderer'; 8 | 9 | // RelayStore.reset( 10 | // new Relay.DefaultNetworkLayer('http://localhost:5000/graphql') 11 | // ); 12 | 13 | const delay = (value) => new Promise(resolve => setTimeout(() => resolve(), value)); 14 | 15 | it('renders correctly', async () => { 16 | const tree = renderer.create( 17 | 18 | ); 19 | 20 | await delay(3000); 21 | 22 | expect(tree.toJSON()).toMatchSnapshot(); 23 | }); 24 | -------------------------------------------------------------------------------- /RelayWeb/src/__tests__/fetch.spec.js: -------------------------------------------------------------------------------- 1 | it('fetches data', async () => { 2 | const response = await fetch('http://localhost:5000/graphql'); 3 | 4 | const data = await response.text(); 5 | 6 | expect(data).not.toBe(null); 7 | }); 8 | -------------------------------------------------------------------------------- /RelayWeb/src/app.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import Relay from 'react-relay'; 3 | import ViewerQuery from './ViewerQuery'; 4 | import { createRenderer } from './RelayUtils'; 5 | import RelayStore from './RelayStore'; 6 | 7 | RelayStore.reset( 8 | new Relay.DefaultNetworkLayer('http://localhost:5000/graphql') 9 | ); 10 | 11 | class RelayApp extends Component { 12 | render() { 13 | console.log('RelayWeb: ', this.props); 14 | 15 | if (!this.props.viewer.users) { 16 | return ( 17 |
18 | No users 19 |
20 | ); 21 | } 22 | 23 | return ( 24 |
25 | name: {this.props.viewer.users.edges[0].node.name} 26 | length: {this.props.viewer.users.edges.length} 27 |
28 | ); 29 | } 30 | } 31 | 32 | // Create a Relay.Renderer container 33 | export default createRenderer(RelayApp, { 34 | queries: ViewerQuery, 35 | fragments: { 36 | viewer: () => Relay.QL` 37 | fragment on Viewer { 38 | users(first: 2) { 39 | edges { 40 | node { 41 | name 42 | } 43 | } 44 | } 45 | } 46 | `, 47 | }, 48 | }); 49 | -------------------------------------------------------------------------------- /RelayWeb/src/config.js: -------------------------------------------------------------------------------- 1 | const config = { 2 | GRAPHQL_URL: process.env.GRAPHQL_URL ? process.env.GRAPHQL_URL : 'http://localhost:5000/graphql', 3 | }; 4 | 5 | export default config; 6 | -------------------------------------------------------------------------------- /RelayWeb/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Relay Integration Test 6 | 12 | 13 | 14 |
15 |
16 | 17 | 18 | -------------------------------------------------------------------------------- /RelayWeb/src/index.js: -------------------------------------------------------------------------------- 1 | import 'babel-polyfill'; 2 | 3 | import { AppContainer } from 'react-hot-loader'; 4 | import React from 'react'; 5 | import { render } from 'react-dom'; 6 | 7 | import App from './app'; 8 | 9 | const rootEl = document.getElementById('root'); 10 | 11 | render( 12 | 13 | 14 | , 15 | rootEl 16 | ); 17 | 18 | if (module.hot) { 19 | module.hot.accept('./app', () => { 20 | const NextApp = require('./app').default; 21 | 22 | render(, 23 | document.getElementById('root') 24 | ); 25 | }); 26 | } 27 | -------------------------------------------------------------------------------- /RelayWeb/test/env.js: -------------------------------------------------------------------------------- 1 | import 'isomorphic-fetch'; 2 | // const XMLHttpRequest = require('xhr2'); 3 | // 4 | // global.XMLHttpRequest = XMLHttpRequest; 5 | 6 | 7 | -------------------------------------------------------------------------------- /RelayWeb/webpack.config.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | 3 | const webpack = require('webpack'); 4 | const path = require('path'); 5 | const HtmlWebpackPlugin = require('html-webpack-plugin'); 6 | const dotEnv = require('dotenv-webpack'); 7 | 8 | const HOST = process.env.HOST || 'localhost'; 9 | const PORT = process.env.PORT || '8000'; 10 | 11 | module.exports = { 12 | entry: [ 13 | 'react-hot-loader/patch', 14 | `webpack-dev-server/client?http://${HOST}:${PORT}`, 15 | `webpack/hot/only-dev-server`, 16 | `./src/index.js` 17 | ], 18 | devtool: 'eval', 19 | output: { 20 | path: path.join(__dirname, 'build'), 21 | filename: 'bundle.js' 22 | }, 23 | resolve: { 24 | extensions: ['', '.js'] 25 | }, 26 | module: { 27 | loaders: [{ 28 | test: /\.js?$/, 29 | exclude: /node_modules/, 30 | loaders: ['babel'], 31 | }] 32 | }, 33 | devServer: { 34 | noInfo: true, 35 | hot: true, 36 | inline: true, 37 | historyApiFallback: true, 38 | port: PORT, 39 | host: HOST 40 | }, 41 | plugins: [ 42 | new webpack.NoErrorsPlugin(), 43 | new webpack.HotModuleReplacementPlugin(), 44 | new HtmlWebpackPlugin({ 45 | template: './src/index.html' 46 | }), 47 | new dotEnv({ 48 | path: './.env' 49 | }), 50 | ] 51 | }; 52 | -------------------------------------------------------------------------------- /RelayWeb/webpack.prod.config.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | 3 | const webpack = require('webpack'); 4 | const path = require('path'); 5 | const HtmlWebpackPlugin = require('html-webpack-plugin'); 6 | const CleanPlugin = require('clean-webpack-plugin'); 7 | const dotEnv = require('dotenv-webpack'); 8 | 9 | module.exports = { 10 | // Default folder for code source 11 | context: path.join(__dirname, './src'), 12 | devtool: 'source-map', 13 | entry: './index.js', 14 | output: { 15 | path: path.join(__dirname, 'console'), 16 | publicPath: '/console/', 17 | filename: '[chunkhash].js' 18 | }, 19 | resolve: { 20 | extensions: ['', '.js'] 21 | }, 22 | module: { 23 | loaders: [{ 24 | test: /\.js?$/, 25 | exclude: /node_modules/, 26 | loaders: ['babel'], 27 | }] 28 | }, 29 | plugins: [ 30 | new webpack.DefinePlugin({ 31 | 'process.env': { 32 | NODE_ENV: '"production"' 33 | } 34 | }), 35 | new webpack.optimize.UglifyJsPlugin({ 36 | compress: { 37 | warnings: false, 38 | screw_ie8: true, 39 | drop_console: true, 40 | drop_debugger: true 41 | } 42 | }), 43 | new webpack.optimize.DedupePlugin(), 44 | new CleanPlugin(['web'], { verbose: false }), 45 | new webpack.optimize.OccurenceOrderPlugin(), 46 | new HtmlWebpackPlugin({ 47 | template: './index.html' 48 | }), 49 | new dotEnv({ 50 | path: './.env', 51 | }) 52 | ] 53 | }; 54 | -------------------------------------------------------------------------------- /server/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | ["transform-flow-strip-types"] 4 | ], 5 | "presets": ["es2015", "stage-0"] 6 | } 7 | 8 | -------------------------------------------------------------------------------- /server/.env: -------------------------------------------------------------------------------- 1 | #Enviroment 2 | NODE_ENV=development 3 | 4 | #GraphQL settings 5 | GRAPHQL_PORT=5000 6 | 7 | #Security 8 | JWT_KEY=awesome_secret_key 9 | -------------------------------------------------------------------------------- /server/.env.example: -------------------------------------------------------------------------------- 1 | #Enviroment 2 | NODE_ENV=development 3 | 4 | #GraphQL settings 5 | GRAPHQL_PORT=5000 6 | 7 | #Security 8 | JWT_KEY=awesome_secret_key 9 | -------------------------------------------------------------------------------- /server/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "airbnb/base", 3 | "parser": "babel-eslint", 4 | "rules": { 5 | "no-console": 0, 6 | "max-len": [1, 120, 2], 7 | "no-param-reassign": [2, { "props": false }], 8 | "no-continue": 0, 9 | "no-underscore-dangle": 0, 10 | "generator-star-spacing": 0, 11 | }, 12 | "env": { 13 | "jest": true 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /server/.flowconfig: -------------------------------------------------------------------------------- 1 | [libs] 2 | interfaces/ 3 | -------------------------------------------------------------------------------- /server/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.sublime-project 3 | *.sublime-workspace 4 | .idea/ 5 | 6 | lib-cov 7 | *.seed 8 | *.log 9 | *.csv 10 | *.dat 11 | *.out 12 | *.pid 13 | *.gz 14 | *.map 15 | 16 | pids 17 | logs 18 | results 19 | 20 | node_modules 21 | npm-debug.log 22 | 23 | dump.rdb 24 | bundle.js 25 | 26 | dist 27 | coverage 28 | .nyc_output 29 | -------------------------------------------------------------------------------- /server/.nvmrc: -------------------------------------------------------------------------------- 1 | 6.9.1 2 | -------------------------------------------------------------------------------- /server/README.md: -------------------------------------------------------------------------------- 1 | # GraphQL DataLoader Boilerplate 2 | 3 | [![CircleCI](https://circleci.com/gh/sibelius/graphql-dataloader-boilerplate.svg?style=svg)](https://circleci.com/gh/sibelius/graphql-dataloader-boilerplate) 4 | [![codecov](https://codecov.io/gh/sibelius/graphql-dataloader-boilerplate/branch/master/graph/badge.svg)](https://codecov.io/gh/sibelius/graphql-dataloader-boilerplate) 5 | 6 | Very simple boilerplate using GraphQL and DataLoader 7 | 8 | ## Command 9 | 10 | #### Setup 11 | ```bash 12 | npm install 13 | ``` 14 | #### Develop 15 | ```bash 16 | npm run watch 17 | ``` 18 | 19 | #### Production 20 | ```bash 21 | # first compile the code 22 | npm run build 23 | 24 | # run graphql compiled server 25 | npm start 26 | ``` 27 | 28 | ### Flow 29 | ```bash 30 | npm run flow 31 | ``` 32 | 33 | Or 34 | ```bash 35 | flow 36 | ``` 37 | 38 | ### REPL server 39 | ```bash 40 | npm run repl 41 | 42 | awesome > M.User.find() 43 | ``` 44 | 45 | ### Schema 46 | Update your schema 47 | ```bash 48 | npm run update-schema 49 | ``` 50 | 51 | Take a look on the [Schema](https://github.com/sibelius/graphql-dataloader-boilerplate/blob/master/data/schema.graphql) 52 | -------------------------------------------------------------------------------- /server/circle.yml: -------------------------------------------------------------------------------- 1 | machine: 2 | node: 3 | version: 4.4.7 4 | post: 5 | - npm install -g npm@3.x.x 6 | test: 7 | post: 8 | - bash <(curl -s https://codecov.io/bash) 9 | -------------------------------------------------------------------------------- /server/data/schema.graphql: -------------------------------------------------------------------------------- 1 | input ChangePasswordInput { 2 | oldPassword: String! 3 | 4 | # user new password 5 | password: String! 6 | clientMutationId: String 7 | } 8 | 9 | type ChangePasswordPayload { 10 | error: String 11 | me: Me 12 | clientMutationId: String 13 | } 14 | 15 | input LoginEmailInput { 16 | email: String! 17 | password: String! 18 | clientMutationId: String 19 | } 20 | 21 | type LoginEmailPayload { 22 | token: String 23 | error: String 24 | clientMutationId: String 25 | } 26 | 27 | # Object with data related and only available to the logged user 28 | type Me implements Node { 29 | # The ID of an object 30 | id: ID! 31 | _id: String 32 | name: String 33 | email: String 34 | active: Boolean 35 | } 36 | 37 | type Mutation { 38 | LoginEmail(input: LoginEmailInput!): LoginEmailPayload 39 | RegisterEmail(input: RegisterEmailInput!): RegisterEmailPayload 40 | ChangePassword(input: ChangePasswordInput!): ChangePasswordPayload 41 | } 42 | 43 | # An object with an ID 44 | interface Node { 45 | # The id of the object. 46 | id: ID! 47 | } 48 | 49 | # Information about pagination in a connection. 50 | type PageInfo { 51 | # When paginating forwards, are there more items? 52 | hasNextPage: Boolean! 53 | 54 | # When paginating backwards, are there more items? 55 | hasPreviousPage: Boolean! 56 | 57 | # When paginating backwards, the cursor to continue. 58 | startCursor: String 59 | 60 | # When paginating forwards, the cursor to continue. 61 | endCursor: String 62 | } 63 | 64 | # The root of all... queries 65 | type Query { 66 | # Fetches an object given its ID 67 | node( 68 | # The ID of an object 69 | id: ID! 70 | ): Node 71 | viewer: Viewer 72 | } 73 | 74 | input RegisterEmailInput { 75 | name: String! 76 | email: String! 77 | password: String! 78 | clientMutationId: String 79 | } 80 | 81 | type RegisterEmailPayload { 82 | token: String 83 | error: String 84 | clientMutationId: String 85 | } 86 | 87 | # User data 88 | type User implements Node { 89 | # The ID of an object 90 | id: ID! 91 | _id: String 92 | name: String 93 | email: String 94 | active: Boolean 95 | } 96 | 97 | # A connection to a list of items. 98 | type UserConnection { 99 | # Information to aid in pagination. 100 | pageInfo: PageInfo! 101 | 102 | # A list of edges. 103 | edges: [UserEdge] 104 | count: Int 105 | } 106 | 107 | # An edge in a connection. 108 | type UserEdge { 109 | # The item at the end of the edge 110 | node: User 111 | 112 | # A cursor for use in pagination 113 | cursor: String! 114 | } 115 | 116 | # ... 117 | type Viewer implements Node { 118 | # The ID of an object 119 | id: ID! 120 | me: Me 121 | user(id: ID!): User 122 | users(after: String, first: Int, before: String, last: Int, search: String): UserConnection 123 | } 124 | -------------------------------------------------------------------------------- /server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "graphql-dataloader-boilerplate", 3 | "description": "GraphQL DataLoader boilerplate", 4 | "version": "0.0.1", 5 | "dependencies": { 6 | "babel-polyfill": "^6.9.1", 7 | "bcrypt-as-promised": "^1.1.0", 8 | "dataloader": "^1.2.0", 9 | "dotenv-safe": "^3.0.0", 10 | "es6-promise": "^4.0.5", 11 | "graphql": "^0.7.0", 12 | "graphql-relay": "^0.4.3", 13 | "isomorphic-fetch": "^2.2.1", 14 | "jsonwebtoken": "^7.1.9", 15 | "koa": "^2.0.0", 16 | "koa-bodyparser": "^2.2.0", 17 | "koa-compose": "^3.1.0", 18 | "koa-convert": "^1.2.0", 19 | "koa-cors": "0.0.16", 20 | "koa-graphql": "^0.5.6", 21 | "koa-logger": "^2.0.0", 22 | "mongoose": "^4.6.7" 23 | }, 24 | "devDependencies": { 25 | "babel-cli": "^6.11.4", 26 | "babel-eslint": "^7.1.0", 27 | "babel-plugin-transform-flow-strip-types": "^6.14.0", 28 | "babel-preset-es2015": "^6.9.0", 29 | "babel-preset-stage-0": "^6.5.0", 30 | "babel-register": "^6.9.0", 31 | "eslint": "^3.10.0", 32 | "eslint-config-airbnb": "^13.0.0", 33 | "eslint-plugin-import": "^2.2.0", 34 | "flow-bin": "^0.35.0", 35 | "jest": "test", 36 | "jest-cli": "test", 37 | "nodemon": "^1.10.2", 38 | "reify": "^0.4.0", 39 | "repl": "^0.1.3", 40 | "repl-promised": "^0.1.0", 41 | "repl.history": "^0.1.3" 42 | }, 43 | "jest": { 44 | "testEnvironment": "node", 45 | "testPathIgnorePatterns": [ 46 | "/node_modules/", 47 | "./dist" 48 | ], 49 | "coverageReporters": [ 50 | "lcov", 51 | "html" 52 | ], 53 | "coverageDirectory": "./coverage/", 54 | "collectCoverage": true, 55 | "moduleNameMapper": { 56 | "^mongoose$": "/node_modules/mongoose" 57 | } 58 | }, 59 | "license": "MIT", 60 | "main": "index.js", 61 | "repository": { 62 | "type": "git", 63 | "url": "https://github.com/sibelius/graphql-dataloader-boilerplate" 64 | }, 65 | "scripts": { 66 | "build": "rm -rf dist/* && babel src --ignore *.spec.js --out-dir dist --copy-files", 67 | "flow": "flow; test $? -eq 0 -o $? -eq 2", 68 | "lint": "eslint src/**", 69 | "repl": "nodemon --config ./repl/nodemon.json ./repl.js --exec babel-node", 70 | "start": "node dist/index.js", 71 | "test": "jest --coverage --forceExit", 72 | "test:watch": "jest --watch --coverage", 73 | "update-schema": "babel-node ./scripts/updateSchema.js", 74 | "watch": "nodemon src/index.js --exec babel-node" 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /server/repl.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import "reify/repl"; 4 | import 'isomorphic-fetch'; 5 | import 'babel-polyfill'; 6 | import REPL from 'repl'; 7 | import replPromised from 'repl-promised'; 8 | import history from 'repl.history'; 9 | 10 | import connectDatabase from './src/database'; 11 | import * as M from './src/models'; 12 | import { generateToken } from './src/auth'; 13 | 14 | (async() => { 15 | try { 16 | const info = await connectDatabase(); 17 | console.log(`Connected to ${info.host}:${info.port}/${info.name}`); 18 | 19 | let repl = REPL.start({ 20 | prompt: 'awesome > ', 21 | }); 22 | repl.context.M = M; 23 | repl.context.generateToken = generateToken; 24 | 25 | history(repl, process.env.HOME+'/.node_history'); 26 | 27 | replPromised.promisify(repl); 28 | } catch (error) { 29 | console.error('Unable to connect to database'); 30 | process.exit(1); 31 | } 32 | })(); 33 | 34 | 35 | -------------------------------------------------------------------------------- /server/repl/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "restartable": false 3 | } 4 | -------------------------------------------------------------------------------- /server/scripts/updateSchema.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env babel-node --optional es7.asyncFunctions 2 | /** 3 | * This file provided by Facebook is for non-commercial testing and evaluation 4 | * purposes only. Facebook reserves all rights not expressly granted. 5 | * 6 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 7 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 8 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 9 | * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 10 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 11 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | */ 13 | 14 | import fs from 'fs'; 15 | import path from 'path'; 16 | import { schema } from '../src/schema'; 17 | import { graphql } from 'graphql'; 18 | import { introspectionQuery, printSchema } from 'graphql/utilities'; 19 | 20 | // Save JSON of full schema introspection for Babel Relay Plugin to use 21 | (async () => { 22 | const result = await (graphql(schema, introspectionQuery)); 23 | if (result.errors) { 24 | console.error( 25 | 'ERROR introspecting schema: ', 26 | JSON.stringify(result.errors, null, 2) 27 | ); 28 | } else { 29 | fs.writeFileSync( 30 | path.join(__dirname, '../data/schema.json'), 31 | JSON.stringify(result, null, 2) 32 | ); 33 | 34 | process.exit(0); 35 | } 36 | })(); 37 | 38 | // Save user readable type system shorthand of schema 39 | fs.writeFileSync( 40 | path.join(__dirname, '../data/schema.graphql'), 41 | printSchema(schema) 42 | ); 43 | -------------------------------------------------------------------------------- /server/src/__tests__/auth.spec.js: -------------------------------------------------------------------------------- 1 | import mongoose from 'mongoose'; 2 | import { graphql } from 'graphql'; 3 | import { schema } from '../schema'; 4 | import { 5 | User, 6 | } from '../models'; 7 | import { setupTest } from '../../test/helper'; 8 | 9 | import { getUser, generateToken } from '../auth'; 10 | 11 | const { ObjectId } = mongoose.Types; 12 | 13 | beforeEach(async () => setupTest()); 14 | 15 | describe('getUser', () => { 16 | it('should return an user null when token is null', async () => { 17 | const token = null; 18 | const { user } = await getUser(token); 19 | 20 | expect(user).toBe(null); 21 | }); 22 | 23 | it('should return null when token is invalid', async () => { 24 | const token = 'invalid token'; 25 | const { user } = await getUser(token); 26 | 27 | expect(user).toBe(null); 28 | }); 29 | 30 | it('should return null when token do not represent a valid user', async () => { 31 | const token = generateToken({ _id: new ObjectId()}); 32 | const { user } = await getUser(token); 33 | 34 | expect(user).toBe(null); 35 | }); 36 | 37 | it('should return user from a valid token', async () => { 38 | const viewer = new User({ 39 | name: 'user', 40 | email: 'user@example.com', 41 | }); 42 | await viewer.save(); 43 | 44 | const token = generateToken(viewer); 45 | const { user } = await getUser(token); 46 | 47 | expect(user.name).toBe(user.name); 48 | expect(user.email).toBe(user.email); 49 | }); 50 | }); 51 | -------------------------------------------------------------------------------- /server/src/app.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import 'isomorphic-fetch'; 4 | 5 | import Koa from 'koa'; 6 | import cors from 'koa-cors'; 7 | import graphqlHTTP from 'koa-graphql'; 8 | import convert from 'koa-convert'; 9 | import logger from 'koa-logger'; 10 | 11 | import { schema } from './schema'; 12 | import { jwtSecret } from './config'; 13 | import { getUser } from './auth'; 14 | 15 | const app = new Koa(); 16 | 17 | app.keys = jwtSecret; 18 | 19 | app.use(logger()); 20 | app.use(convert(cors())); 21 | app.use(convert(graphqlHTTP(async (req) => { 22 | const { user } = await getUser(req.header.authorization); 23 | 24 | return { 25 | graphiql: true, 26 | schema, 27 | context: { 28 | user, 29 | }, 30 | formatError: (error) => { 31 | console.log(error.message); 32 | console.log(error.locations); 33 | console.log(error.stack); 34 | 35 | return { 36 | message: error.message, 37 | locations: error.locations, 38 | stack: error.stack, 39 | }; 40 | }, 41 | }; 42 | }))); 43 | 44 | export default app; 45 | -------------------------------------------------------------------------------- /server/src/auth.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import jwt from 'jsonwebtoken'; 4 | import { User } from './models'; 5 | import { jwtSecret } from './config'; 6 | 7 | export async function getUser(token: string) { 8 | if (!token) return { user: null }; 9 | 10 | try { 11 | const decodedToken = jwt.verify(token.substring(4), jwtSecret); 12 | 13 | const user = await User.findOne({ _id: decodedToken.id }); 14 | 15 | return { 16 | user, 17 | }; 18 | } catch (err) { 19 | return { user: null }; 20 | } 21 | } 22 | 23 | type UserType = { 24 | _id: string, 25 | } 26 | 27 | export function generateToken(user: UserType) { 28 | return `JWT ${jwt.sign({ id: user._id }, jwtSecret)}`; 29 | } 30 | -------------------------------------------------------------------------------- /server/src/config.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import path from 'path'; 4 | import dotenvSafe from 'dotenv-safe'; 5 | 6 | const root = path.join.bind(this, __dirname, '../'); 7 | 8 | dotenvSafe.load({ 9 | path: root('.env'), 10 | sample: root('.env.example'), 11 | }); 12 | 13 | // Database Settings 14 | const dBdevelopment = 'mongodb://localhost/awesome'; 15 | const dBproduction = 'mongodb://localhost/awesome'; 16 | 17 | // Test Database Settings 18 | // const test = 'mongodb://localhost/awesome-test'; 19 | 20 | // Export DB Settings 21 | export const databaseConfig = (process.env.NODE_ENV === 'production') ? dBproduction : dBdevelopment; 22 | 23 | // Export GraphQL Server settings 24 | export const graphqlPort = process.env.GRAPHQL_PORT || 5000; 25 | export const jwtSecret = process.env.JWT_KEY || 'secret_key'; 26 | -------------------------------------------------------------------------------- /server/src/connection/ConnectionFromMongoCursor.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | export default class ConnectionFromMongoCursor { 4 | 5 | static PREFIX = 'mongo:'; 6 | 7 | static base64 = str => (new Buffer(str, 'ascii')).toString('base64'); 8 | static unbase64 = b64 => (new Buffer(b64, 'base64')).toString('ascii'); 9 | 10 | /** 11 | * Rederives the offset from the cursor string 12 | */ 13 | static cursorToOffset(cursor) { 14 | return parseInt(ConnectionFromMongoCursor.unbase64(cursor).substring(ConnectionFromMongoCursor.PREFIX.length), 10); 15 | } 16 | 17 | /** 18 | * Given an optional cursor and a default offset, returns the offset to use; 19 | * if the cursor contains a valid offset, that will be used, otherwise it will 20 | * be the default. 21 | */ 22 | static getOffsetWithDefault(cursor, defaultOffset) { 23 | if (cursor === undefined) { 24 | return defaultOffset; 25 | } 26 | const offset = ConnectionFromMongoCursor.cursorToOffset(cursor); 27 | return isNaN(offset) ? defaultOffset : offset; 28 | } 29 | 30 | /** 31 | * Creates the cursor string from an offset. 32 | */ 33 | static offsetToCursor(offset) { 34 | return ConnectionFromMongoCursor.base64(ConnectionFromMongoCursor.PREFIX + offset); 35 | } 36 | 37 | /** 38 | * Accepts a mongodb cursor and connection arguments, and returns a connection 39 | * object for use in GraphQL. It uses array offsets as pagination, so pagiantion 40 | * will work only if the data set is satic. 41 | */ 42 | static async connectionFromMongoCursor(viewer, inMongoCursor, args = {}, loader) { 43 | const mongodbCursor = inMongoCursor; 44 | const { after, before } = args; 45 | let { first, last } = args; 46 | 47 | // Limit the maximum number of elements in a query 48 | if (!first && !last) first = 10; 49 | if (first > 1000) first = 1000; 50 | if (last > 1000) last = 1000; 51 | 52 | const count = await inMongoCursor.count(); 53 | // returning mongoose query obj to find again after count 54 | inMongoCursor.find(); 55 | 56 | const beforeOffset = ConnectionFromMongoCursor.getOffsetWithDefault(before, count); 57 | const afterOffset = ConnectionFromMongoCursor.getOffsetWithDefault(after, -1); 58 | 59 | 60 | let startOffset = Math.max(-1, afterOffset) + 1; 61 | let endOffset = Math.min(count, beforeOffset); 62 | 63 | if (first !== undefined) { 64 | endOffset = Math.min(endOffset, startOffset + first); 65 | } 66 | if (last !== undefined) { 67 | startOffset = Math.max(startOffset, endOffset - last); 68 | } 69 | 70 | const skip = Math.max(startOffset, 0); 71 | 72 | 73 | const limit = endOffset - startOffset; 74 | 75 | // If supplied slice is too large, trim it down before mapping over it. 76 | mongodbCursor.skip(skip); 77 | mongodbCursor.limit(limit); 78 | 79 | 80 | // Short circuit if limit is 0; in that case, mongodb doesn't limit at all 81 | const slice = await mongodbCursor.exec(); 82 | 83 | const edges = slice.map((value, index) => ({ 84 | cursor: ConnectionFromMongoCursor.offsetToCursor(startOffset + index), 85 | node: loader(viewer, value._id), 86 | })); 87 | 88 | const firstEdge = edges[0]; 89 | const lastEdge = edges[edges.length - 1]; 90 | const lowerBound = after ? (afterOffset + 1) : 0; 91 | const upperBound = before ? Math.min(beforeOffset, count) : count; 92 | 93 | return { 94 | edges, 95 | count, 96 | pageInfo: { 97 | startCursor: firstEdge ? firstEdge.cursor : null, 98 | endCursor: lastEdge ? lastEdge.cursor : null, 99 | hasPreviousPage: last !== null ? startOffset > lowerBound : false, 100 | hasNextPage: first !== null ? endOffset < upperBound : false, 101 | }, 102 | }; 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /server/src/connection/UserConnection.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import { 4 | GraphQLInt, 5 | } from 'graphql'; 6 | 7 | import { 8 | connectionDefinitions, 9 | } from 'graphql-relay'; 10 | 11 | import UserType from '../type/UserType'; 12 | 13 | export default connectionDefinitions({ 14 | name: 'User', 15 | nodeType: UserType, 16 | connectionFields: { 17 | count: { 18 | type: GraphQLInt, 19 | }, 20 | }, 21 | }); 22 | -------------------------------------------------------------------------------- /server/src/database.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | 4 | import mongoose from 'mongoose'; 5 | import { databaseConfig } from './config'; 6 | 7 | export default function connectDatabase() { 8 | return new Promise((resolve, reject) => { 9 | mongoose.Promise = global.Promise; 10 | mongoose.connection 11 | .on('error', error => reject(error)) 12 | .on('close', () => console.log('Database connection closed.')) 13 | .once('open', () => resolve(mongoose.connections[0])); 14 | 15 | mongoose.connect(databaseConfig); 16 | }); 17 | } 18 | -------------------------------------------------------------------------------- /server/src/index.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | import 'babel-polyfill'; 3 | import app from './app'; 4 | import connectDatabase from './database'; 5 | import { graphqlPort } from './config'; 6 | 7 | (async () => { 8 | try { 9 | const info = await connectDatabase(); 10 | console.log(`Connected to ${info.host}:${info.port}/${info.name}`); 11 | } catch (error) { 12 | console.error('Unable to connect to database'); 13 | process.exit(1); 14 | } 15 | 16 | await app.listen(graphqlPort); 17 | console.log(`Server started on port ${graphqlPort}`); 18 | })(); 19 | -------------------------------------------------------------------------------- /server/src/interface/NodeInterface.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import { nodeDefinitions, fromGlobalId } from 'graphql-relay'; 4 | 5 | import ViewerLoader from '../loader/ViewerLoader'; 6 | import ViewerType from '../type/ViewerType'; 7 | 8 | import UserLoader from '../loader/UserLoader'; 9 | import UserType from '../type/UserType'; 10 | 11 | const { 12 | nodeField, 13 | nodeInterface, 14 | } = nodeDefinitions( 15 | // A method that maps from a global id to an object 16 | async (globalId, { user }) => { 17 | const { id, type } = fromGlobalId(globalId); 18 | 19 | // console.log('id, type: ', type, id, globalId); 20 | if (type === 'User') { 21 | return await UserLoader.load(user, id); 22 | } 23 | if (type === 'Viewer') { 24 | return await ViewerLoader.load(id); 25 | } 26 | }, 27 | // A method that maps from an object to a type 28 | (obj) => { 29 | // console.log('obj: ', typeof obj, obj.constructor); 30 | if (obj instanceof UserLoader) { 31 | return UserType; 32 | } 33 | if (obj instanceof ViewerLoader) { 34 | return ViewerType; 35 | } 36 | }, 37 | ); 38 | 39 | export const NodeInterface = nodeInterface; 40 | export const NodeField = nodeField; 41 | -------------------------------------------------------------------------------- /server/src/interface/__tests__/NodeInterface.spec.js: -------------------------------------------------------------------------------- 1 | import { graphql } from 'graphql'; 2 | import { toGlobalId } from 'graphql-relay'; 3 | import { schema } from '../../schema'; 4 | import { 5 | User, 6 | } from '../../models'; 7 | import { setupTest } from '../../../test/helper'; 8 | 9 | beforeEach(async () => await setupTest()); 10 | 11 | it('should load Viewer', async () => { 12 | const user = new User({ 13 | name: 'user', 14 | email: 'user@example.com', 15 | }); 16 | await user.save(); 17 | 18 | const query = ` 19 | query Q { 20 | node(id: "${toGlobalId('Viewer', user._id)}") { 21 | ... on Viewer { 22 | me { 23 | name 24 | } 25 | } 26 | } 27 | } 28 | `; 29 | 30 | const rootValue = {}; 31 | const context = { user }; 32 | 33 | const result = await graphql(schema, query, rootValue, context); 34 | const { node } = result.data; 35 | 36 | expect(node.me.name).toBe(user.name); 37 | }); 38 | 39 | it('should load User', async () => { 40 | const user = new User({ 41 | name: 'user', 42 | email: 'user@example.com', 43 | }); 44 | await user.save(); 45 | 46 | const query = ` 47 | query Q { 48 | node(id: "${toGlobalId('User', user._id)}") { 49 | ... on User { 50 | name 51 | } 52 | } 53 | } 54 | `; 55 | 56 | const rootValue = {}; 57 | const context = {}; 58 | 59 | const result = await graphql(schema, query, rootValue, context); 60 | const { node } = result.data; 61 | 62 | expect(node.name).toBe(user.name); 63 | }); 64 | -------------------------------------------------------------------------------- /server/src/loader/UserLoader.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | import DataLoader from 'dataloader'; 3 | import { User as UserModel } from '../models'; 4 | import ConnectionFromMongoCursor from '../connection/ConnectionFromMongoCursor'; 5 | 6 | type UserType = { 7 | id: string, 8 | _id: string, 9 | name: string, 10 | email: string, 11 | active: boolean, 12 | } 13 | 14 | export default class User { 15 | id: string; 16 | _id: string; 17 | name: string; 18 | email: string; 19 | active: boolean; 20 | 21 | static userLoader = new DataLoader( 22 | ids => Promise.all(ids.map(id => UserModel.findOne({ _id: id }))), 23 | ); 24 | 25 | constructor(data: UserType, viewer) { 26 | this.id = data.id; 27 | this._id = data._id; 28 | this.name = data.name; 29 | 30 | // you can only see your own email, and your active status 31 | if (viewer && viewer._id.equals(data._id)) { 32 | this.email = data.email; 33 | this.active = data.active; 34 | } 35 | } 36 | 37 | static viewerCanSee(viewer, data) { 38 | // Anyone can se another user 39 | return true; 40 | } 41 | 42 | static async load(viewer, id) { 43 | if (!id) return null; 44 | 45 | const data = await User.userLoader.load(id); 46 | 47 | if (!data) return null; 48 | 49 | console.log('data: ', data); 50 | 51 | return User.viewerCanSee(viewer, data) ? new User(data, viewer) : null; 52 | } 53 | 54 | static async loadUsers(viewer, args) { 55 | const where = args.search ? { name: { $regex: new RegExp(`^${args.search}`, 'ig') } } : {}; 56 | const users = UserModel 57 | .find(where, { _id: 1 }); 58 | 59 | return ConnectionFromMongoCursor.connectionFromMongoCursor(viewer, users, args, User.load); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /server/src/loader/ViewerLoader.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | type ViewerType = { 4 | id: ?string, 5 | } 6 | 7 | export default class Viewer { 8 | id: ?string; 9 | 10 | constructor(data: ViewerType) { 11 | this.id = data.id; 12 | } 13 | 14 | static async load(userId) { 15 | const data = { 16 | id: userId, 17 | }; 18 | 19 | return new Viewer(data); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /server/src/models/User.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | 4 | import mongoose from 'mongoose'; 5 | import bcrypt from 'bcrypt-as-promised'; 6 | 7 | const Schema = new mongoose.Schema({ 8 | name: { 9 | type: String, 10 | required: true, 11 | }, 12 | password: { 13 | type: String, 14 | hidden: true, 15 | }, 16 | email: { 17 | type: String, 18 | required: false, 19 | index: true, 20 | }, 21 | active: { 22 | type: Boolean, 23 | default: true, 24 | }, 25 | }, { 26 | timestamps: { 27 | createdAt: 'createdAt', 28 | updatedAt: 'updatedAt', 29 | }, 30 | collection: 'user', 31 | }); 32 | 33 | Schema 34 | .pre('save', function (next) { 35 | // Hash the password 36 | if (this.isModified('password')) { 37 | this.encryptPassword(this.password) 38 | .then((hash) => { 39 | this.password = hash; 40 | next(); 41 | }) 42 | .catch(err => next(err)); 43 | } else { 44 | return next(); 45 | } 46 | }); 47 | 48 | Schema.methods = { 49 | async authenticate(plainTextPassword) { 50 | try { 51 | return await bcrypt.compare(plainTextPassword, this.password); 52 | } catch (err) { 53 | return false; 54 | } 55 | }, 56 | encryptPassword(password) { 57 | return bcrypt.hash(password, 8); 58 | }, 59 | }; 60 | 61 | 62 | export default mongoose.model('User', Schema); 63 | -------------------------------------------------------------------------------- /server/src/models/index.js: -------------------------------------------------------------------------------- 1 | export User from './User'; 2 | -------------------------------------------------------------------------------- /server/src/mutation/ChangePasswordMutation.js: -------------------------------------------------------------------------------- 1 | import { 2 | GraphQLString, 3 | GraphQLNonNull, 4 | } from 'graphql'; 5 | import { 6 | mutationWithClientMutationId, 7 | } from 'graphql-relay'; 8 | import MeType from '../type/MeType'; 9 | 10 | export default mutationWithClientMutationId({ 11 | name: 'ChangePassword', 12 | inputFields: { 13 | oldPassword: { 14 | type: new GraphQLNonNull(GraphQLString), 15 | }, 16 | password: { 17 | type: new GraphQLNonNull(GraphQLString), 18 | description: 'user new password', 19 | }, 20 | }, 21 | mutateAndGetPayload: async ({ oldPassword, password }, { user }) => { 22 | if (!user) { 23 | throw new Error('invalid user'); 24 | } 25 | 26 | const correctPassword = await user.authenticate(oldPassword); 27 | 28 | if (!correctPassword) { 29 | return { 30 | error: 'INVALID_PASSWORD', 31 | }; 32 | } 33 | 34 | user.password = password; 35 | await user.save(); 36 | 37 | return { 38 | error: null, 39 | }; 40 | }, 41 | outputFields: { 42 | error: { 43 | type: GraphQLString, 44 | resolve: ({ error }) => error, 45 | }, 46 | me: { 47 | type: MeType, 48 | resolve: (obj, args, context) => 49 | context.user 50 | , 51 | }, 52 | }, 53 | }); 54 | -------------------------------------------------------------------------------- /server/src/mutation/LoginEmailMutation.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import { GraphQLString, GraphQLNonNull } from 'graphql'; 4 | import { mutationWithClientMutationId } from 'graphql-relay'; 5 | 6 | import { User } from '../models'; 7 | import { generateToken } from '../auth'; 8 | 9 | export default mutationWithClientMutationId({ 10 | name: 'LoginEmail', 11 | inputFields: { 12 | email: { 13 | type: new GraphQLNonNull(GraphQLString), 14 | }, 15 | password: { 16 | type: new GraphQLNonNull(GraphQLString), 17 | }, 18 | }, 19 | mutateAndGetPayload: async ({ email, password }) => { 20 | const user = await User.findOne({ email: email.toLowerCase() }); 21 | 22 | if (!user) { 23 | return { 24 | token: null, 25 | error: 'INVALID_EMAIL_PASSWORD', 26 | }; 27 | } 28 | 29 | const correctPassword = await user.authenticate(password); 30 | 31 | if (!correctPassword) { 32 | return { 33 | token: null, 34 | error: 'INVALID_EMAIL_PASSWORD', 35 | }; 36 | } 37 | 38 | return { 39 | token: generateToken(user), 40 | error: null, 41 | }; 42 | }, 43 | outputFields: { 44 | token: { 45 | type: GraphQLString, 46 | resolve: ({ token }) => token, 47 | }, 48 | error: { 49 | type: GraphQLString, 50 | resolve: ({ error }) => error, 51 | }, 52 | }, 53 | }); 54 | -------------------------------------------------------------------------------- /server/src/mutation/RegisterEmail.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import { 4 | GraphQLString, 5 | GraphQLNonNull, 6 | } from 'graphql'; 7 | import { 8 | mutationWithClientMutationId, 9 | } from 'graphql-relay'; 10 | import { 11 | User, 12 | } from '../models'; 13 | import { generateToken } from '../auth'; 14 | 15 | export default mutationWithClientMutationId({ 16 | name: 'RegisterEmail', 17 | inputFields: { 18 | name: { 19 | type: new GraphQLNonNull(GraphQLString), 20 | }, 21 | email: { 22 | type: new GraphQLNonNull(GraphQLString), 23 | }, 24 | password: { 25 | type: new GraphQLNonNull(GraphQLString), 26 | }, 27 | }, 28 | mutateAndGetPayload: async ({ name, email, password }) => { 29 | let user = await User.findOne({ email: email.toLowerCase() }); 30 | 31 | if (user) { 32 | return { 33 | token: null, 34 | error: 'EMAIL_ALREADY_IN_USE', 35 | }; 36 | } 37 | 38 | user = new User({ 39 | name, 40 | email, 41 | password, 42 | }); 43 | await user.save(); 44 | 45 | return { 46 | token: generateToken(user), 47 | error: null, 48 | }; 49 | }, 50 | outputFields: { 51 | token: { 52 | type: GraphQLString, 53 | resolve: ({ token }) => token, 54 | }, 55 | error: { 56 | type: GraphQLString, 57 | resolve: ({ error }) => error, 58 | }, 59 | }, 60 | }); 61 | -------------------------------------------------------------------------------- /server/src/mutation/__tests__/ChangePasswordMutation.spec.js: -------------------------------------------------------------------------------- 1 | import { graphql } from 'graphql'; 2 | import { schema } from '../../schema'; 3 | import { 4 | User, 5 | } from '../../models'; 6 | import { generateToken } from '../../auth'; 7 | import { setupTest } from '../../../test/helper'; 8 | 9 | beforeEach(async () => setupTest()); 10 | 11 | it('should not change password of non authorized user', async () => { 12 | const query = ` 13 | mutation M { 14 | ChangePassword(input: { 15 | clientMutationId: "abc" 16 | oldPassword: "old" 17 | password: "new" 18 | }) { 19 | clientMutationId 20 | error 21 | } 22 | } 23 | `; 24 | 25 | const rootValue = {}; 26 | const context = {}; 27 | 28 | const result = await graphql(schema, query, rootValue, context); 29 | const { errors } = result; 30 | 31 | expect(errors.length).toBe(1) 32 | expect(errors[0].message).toBe('invalid user'); 33 | }); 34 | 35 | it('should not change password if oldPassword is invalid', async () => { 36 | const user = new User({ 37 | name: 'user', 38 | email: 'awesome@example.com', 39 | password: 'awesome', 40 | }); 41 | await user.save(); 42 | 43 | const query = ` 44 | mutation M { 45 | ChangePassword(input: { 46 | clientMutationId: "abc" 47 | oldPassword: "old" 48 | password: "new" 49 | }) { 50 | clientMutationId 51 | error 52 | } 53 | } 54 | `; 55 | 56 | const rootValue = {}; 57 | const context = { user }; 58 | 59 | const result = await graphql(schema, query, rootValue, context); 60 | const { ChangePassword } = result.data; 61 | 62 | expect(ChangePassword.error).toBe('INVALID_PASSWORD'); 63 | }); 64 | 65 | it('should change password if oldPassword is correct', async () => { 66 | const password = 'awesome'; 67 | 68 | const user = new User({ 69 | name: 'user', 70 | email: 'awesome@example.com', 71 | password, 72 | }); 73 | await user.save(); 74 | 75 | const query = ` 76 | mutation M { 77 | ChangePassword(input: { 78 | clientMutationId: "abc" 79 | oldPassword: "${password}" 80 | password: "new" 81 | }) { 82 | clientMutationId 83 | error 84 | } 85 | } 86 | `; 87 | 88 | const rootValue = {}; 89 | const context = { user }; 90 | 91 | const result = await graphql(schema, query, rootValue, context); 92 | const { ChangePassword } = result.data; 93 | 94 | expect(ChangePassword.error).toBe(null); 95 | }); 96 | -------------------------------------------------------------------------------- /server/src/mutation/__tests__/LoginEmailMutation.spec.js: -------------------------------------------------------------------------------- 1 | import { graphql } from 'graphql'; 2 | import { schema } from '../../schema'; 3 | import { 4 | User, 5 | } from '../../models'; 6 | import { generateToken } from '../../auth'; 7 | import { setupTest } from '../../../test/helper'; 8 | 9 | beforeEach(async () => setupTest()); 10 | 11 | it('should not login if email is not in the database', async () => { 12 | const query = ` 13 | mutation M { 14 | LoginEmail(input: { 15 | clientMutationId: "abc" 16 | email: "awesome@example.com" 17 | password: "awesome" 18 | }) { 19 | clientMutationId 20 | token 21 | error 22 | } 23 | } 24 | `; 25 | 26 | const rootValue = {}; 27 | const context = {}; 28 | 29 | const result = await graphql(schema, query, rootValue, context); 30 | const { LoginEmail } = result.data; 31 | 32 | 33 | expect(LoginEmail.token).toBe(null); 34 | expect(LoginEmail.error).toBe('INVALID_EMAIL_PASSWORD'); 35 | }); 36 | 37 | it('should not login with wrong email', async () => { 38 | const user = new User({ 39 | name: 'user', 40 | email: 'awesome@example.com', 41 | password: 'awesome', 42 | }); 43 | await user.save(); 44 | 45 | const query = ` 46 | mutation M { 47 | LoginEmail(input: { 48 | clientMutationId: "abc" 49 | email: "awesome@example.com" 50 | password: "notawesome" 51 | }) { 52 | clientMutationId 53 | token 54 | error 55 | } 56 | } 57 | `; 58 | 59 | const rootValue = {}; 60 | const context = {}; 61 | 62 | const result = await graphql(schema, query, rootValue, context); 63 | const { LoginEmail } = result.data; 64 | 65 | expect(LoginEmail.token).toBe(null); 66 | expect(LoginEmail.error).toBe('INVALID_EMAIL_PASSWORD'); 67 | }); 68 | 69 | it('should generate token when email and password is correct', async () => { 70 | const email = 'awesome@example.com'; 71 | const password = 'awesome'; 72 | 73 | const user = new User({ 74 | name: 'user', 75 | email, 76 | password, 77 | }); 78 | await user.save(); 79 | 80 | const query = ` 81 | mutation M { 82 | LoginEmail(input: { 83 | clientMutationId: "abc" 84 | email: "${email}" 85 | password: "${password}" 86 | }) { 87 | clientMutationId 88 | token 89 | error 90 | } 91 | } 92 | `; 93 | 94 | const rootValue = {}; 95 | const context = {}; 96 | 97 | const result = await graphql(schema, query, rootValue, context); 98 | const { LoginEmail } = result.data; 99 | 100 | expect(LoginEmail.token).toBe(generateToken(user)); 101 | expect(LoginEmail.error).toBe(null); 102 | }); 103 | -------------------------------------------------------------------------------- /server/src/mutation/__tests__/RegisterEmailMutation.spec.js: -------------------------------------------------------------------------------- 1 | import { graphql } from 'graphql'; 2 | import { schema } from '../../schema'; 3 | import { 4 | User, 5 | } from '../../models'; 6 | import { generateToken } from '../../auth'; 7 | import { setupTest } from '../../../test/helper'; 8 | 9 | beforeEach(async () => setupTest()); 10 | 11 | it('should not register with the an existing email', async () => { 12 | const user = new User({ 13 | name: 'awesome', 14 | email: 'awesome@example.com', 15 | }); 16 | await user.save(); 17 | 18 | const query = ` 19 | mutation M { 20 | RegisterEmail(input: { 21 | clientMutationId: "abc" 22 | name: "Awesome" 23 | email: "awesome@example.com" 24 | password: "awesome" 25 | }) { 26 | clientMutationId 27 | token 28 | error 29 | } 30 | } 31 | `; 32 | 33 | const rootValue = {}; 34 | const context = {}; 35 | 36 | const result = await graphql(schema, query, rootValue, context); 37 | const { RegisterEmail } = result.data; 38 | 39 | expect(RegisterEmail.token).toBe(null); 40 | expect(RegisterEmail.error).toBe('EMAIL_ALREADY_IN_USE'); 41 | }); 42 | 43 | it('should create a new user with parameters are valid', async () => { 44 | const email = 'awesome@example.com'; 45 | 46 | const query = ` 47 | mutation M { 48 | RegisterEmail(input: { 49 | clientMutationId: "abc" 50 | name: "Awesome" 51 | email: "${email}" 52 | password: "awesome" 53 | }) { 54 | clientMutationId 55 | token 56 | error 57 | } 58 | } 59 | `; 60 | 61 | const rootValue = {}; 62 | const context = {}; 63 | 64 | const result = await graphql(schema, query, rootValue, context); 65 | const { RegisterEmail } = result.data; 66 | 67 | const user = await User.findOne({ 68 | email, 69 | }); 70 | 71 | expect(user).not.toBe(null); 72 | expect(RegisterEmail.token).toBe(generateToken(user)); 73 | expect(RegisterEmail.error).toBe(null); 74 | }); 75 | -------------------------------------------------------------------------------- /server/src/schema.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import { GraphQLSchema } from 'graphql'; 4 | 5 | import QueryType from './type/QueryType'; 6 | import MutationType from './type/MutationType'; 7 | 8 | export const schema = new GraphQLSchema({ 9 | query: QueryType, 10 | mutation: MutationType, 11 | }); 12 | -------------------------------------------------------------------------------- /server/src/type/MeType.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import { 4 | GraphQLObjectType, 5 | GraphQLString, 6 | GraphQLBoolean, 7 | } from 'graphql'; 8 | import { 9 | globalIdField, 10 | } from 'graphql-relay'; 11 | import { 12 | NodeInterface, 13 | } from '../interface/NodeInterface'; 14 | 15 | export default new GraphQLObjectType({ 16 | name: 'Me', 17 | description: 'Object with data related and only available to the logged user', 18 | fields: () => ({ 19 | id: globalIdField('Me'), 20 | _id: { 21 | type: GraphQLString, 22 | resolve: user => user._id, 23 | }, 24 | name: { 25 | type: GraphQLString, 26 | resolve: user => user.name, 27 | }, 28 | email: { 29 | type: GraphQLString, 30 | resolve: user => user.email, 31 | }, 32 | active: { 33 | type: GraphQLBoolean, 34 | resolve: user => user.active, 35 | }, 36 | }), 37 | interfaces: () => [NodeInterface], 38 | }); 39 | -------------------------------------------------------------------------------- /server/src/type/MutationType.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import { 4 | GraphQLObjectType, 5 | } from 'graphql'; 6 | 7 | import LoginEmail from '../mutation/LoginEmailMutation'; 8 | import RegisterEmail from '../mutation/RegisterEmail'; 9 | import ChangePassword from '../mutation/ChangePasswordMutation'; 10 | 11 | export default new GraphQLObjectType({ 12 | name: 'Mutation', 13 | fields: () => ({ 14 | // auth 15 | LoginEmail, 16 | RegisterEmail, 17 | ChangePassword, 18 | }), 19 | }); 20 | -------------------------------------------------------------------------------- /server/src/type/QueryType.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import { GraphQLObjectType } from 'graphql'; 4 | import { NodeField } from '../interface/NodeInterface'; 5 | 6 | import ViewerLoader from '../loader/ViewerLoader'; 7 | import ViewerType from './ViewerType'; 8 | 9 | export default new GraphQLObjectType({ 10 | name: 'Query', 11 | description: 'The root of all... queries', 12 | fields: () => ({ 13 | node: NodeField, 14 | viewer: { 15 | type: ViewerType, 16 | args: {}, 17 | resolve: async (obj, args, { user }) => 18 | await ViewerLoader.load(user ? user._id : null) 19 | , 20 | }, 21 | }), 22 | }); 23 | -------------------------------------------------------------------------------- /server/src/type/UserType.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import { 4 | GraphQLObjectType, 5 | GraphQLString, 6 | GraphQLBoolean, 7 | } from 'graphql'; 8 | import { 9 | globalIdField, 10 | } from 'graphql-relay'; 11 | import { 12 | NodeInterface, 13 | } from '../interface/NodeInterface'; 14 | 15 | export default new GraphQLObjectType({ 16 | name: 'User', 17 | description: 'User data', 18 | fields: () => ({ 19 | id: globalIdField('User'), 20 | _id: { 21 | type: GraphQLString, 22 | resolve: user => user._id, 23 | }, 24 | name: { 25 | type: GraphQLString, 26 | resolve: user => user.name, 27 | }, 28 | email: { 29 | type: GraphQLString, 30 | resolve: user => user.email, 31 | }, 32 | active: { 33 | type: GraphQLBoolean, 34 | resolve: user => user.active, 35 | }, 36 | }), 37 | interfaces: () => [NodeInterface], 38 | }); 39 | -------------------------------------------------------------------------------- /server/src/type/ViewerType.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import { 4 | GraphQLObjectType, 5 | GraphQLString, 6 | GraphQLNonNull, 7 | GraphQLID, 8 | } from 'graphql'; 9 | import { 10 | globalIdField, 11 | connectionArgs, 12 | fromGlobalId, 13 | } from 'graphql-relay'; 14 | import { NodeInterface } from '../interface/NodeInterface'; 15 | 16 | 17 | import MeType from './MeType'; 18 | 19 | import UserType from './UserType'; 20 | import UserLoader from '../loader/UserLoader'; 21 | import UserConnection from '../connection/UserConnection'; 22 | 23 | export default new GraphQLObjectType({ 24 | name: 'Viewer', 25 | description: '...', 26 | fields: () => ({ 27 | id: globalIdField('Viewer'), 28 | me: { 29 | type: MeType, 30 | resolve: (root, args, { user }) => user, 31 | }, 32 | user: { 33 | type: UserType, 34 | args: { 35 | id: { 36 | type: new GraphQLNonNull(GraphQLID), 37 | }, 38 | }, 39 | resolve: (obj, args, { user }) => { 40 | const { id } = fromGlobalId(args.id); 41 | return UserLoader.load(user, id); 42 | }, 43 | }, 44 | users: { 45 | type: UserConnection.connectionType, 46 | args: { 47 | ...connectionArgs, 48 | search: { 49 | type: GraphQLString, 50 | }, 51 | }, 52 | resolve: (obj, args, { user }) => { 53 | console.log('getUsers: ', user, args); 54 | return UserLoader.loadUsers(user, args) 55 | }, 56 | }, 57 | }), 58 | interfaces: () => [NodeInterface], 59 | }); 60 | -------------------------------------------------------------------------------- /server/src/type/__tests__/MeType.spec.js: -------------------------------------------------------------------------------- 1 | import { graphql } from 'graphql'; 2 | import { schema } from '../../schema'; 3 | import { 4 | User, 5 | } from '../../models'; 6 | import { setupTest } from '../../../test/helper'; 7 | 8 | beforeEach(async () => setupTest()); 9 | 10 | it('should be null when user is not logged in', async () => { 11 | const query = ` 12 | query Q { 13 | viewer { 14 | me { 15 | name 16 | } 17 | } 18 | } 19 | `; 20 | 21 | const rootValue = {}; 22 | const context = {}; 23 | 24 | const result = await graphql(schema, query, rootValue, context); 25 | const { data } = result; 26 | 27 | expect(data.viewer.me).toBe(null); 28 | }); 29 | 30 | it('should return the current user when user is logged in', async () => { 31 | const user = new User({ 32 | name: 'user', 33 | email: 'user@example.com', 34 | }); 35 | await user.save(); 36 | 37 | const query = ` 38 | query Q { 39 | viewer { 40 | me { 41 | _id 42 | name 43 | email 44 | active 45 | } 46 | } 47 | } 48 | `; 49 | 50 | const rootValue = {}; 51 | const context = { user }; 52 | 53 | const result = await graphql(schema, query, rootValue, context); 54 | const { data } = result; 55 | 56 | expect(data.viewer.me.name).toBe(user.name); 57 | }); 58 | -------------------------------------------------------------------------------- /server/src/type/__tests__/UserType.spec.js: -------------------------------------------------------------------------------- 1 | import { graphql } from 'graphql'; 2 | import { schema } from '../../schema'; 3 | import { 4 | User, 5 | } from '../../models'; 6 | import { setupTest } from '../../../test/helper'; 7 | 8 | beforeEach(async () => setupTest()); 9 | 10 | it('should not show email of other users', async () => { 11 | const user = new User({ 12 | name: 'user', 13 | email: 'user@example.com', 14 | }); 15 | await user.save(); 16 | 17 | const user1 = new User({ 18 | name: 'awesome', 19 | email: 'awesome@example.com', 20 | }); 21 | await user1.save(); 22 | 23 | const query = ` 24 | query Q { 25 | viewer { 26 | users(first: 2) { 27 | edges { 28 | node { 29 | _id 30 | name 31 | email 32 | active 33 | } 34 | } 35 | } 36 | } 37 | } 38 | `; 39 | 40 | const rootValue = {}; 41 | const context = { user }; 42 | 43 | const result = await graphql(schema, query, rootValue, context); 44 | const { edges } = result.data.viewer.users; 45 | 46 | expect(edges[0].node.name).toBe(user.name); 47 | expect(edges[0].node.email).toBe(user.email); 48 | 49 | expect(edges[1].node.name).toBe(user1.name); 50 | expect(edges[1].node.email).toBe(null); 51 | }); 52 | -------------------------------------------------------------------------------- /server/src/type/__tests__/ViewerType.spec.js: -------------------------------------------------------------------------------- 1 | import { graphql } from 'graphql'; 2 | import { toGlobalId } from 'graphql-relay'; 3 | import { schema } from '../../schema'; 4 | import { 5 | User, 6 | } from '../../models'; 7 | import { setupTest } from '../../../test/helper'; 8 | 9 | beforeEach(async () => setupTest()); 10 | 11 | it('should get user by id', async () => { 12 | const user = new User({ 13 | name: 'user', 14 | email: 'user@example.com', 15 | }); 16 | await user.save(); 17 | 18 | const query = ` 19 | query Q { 20 | viewer { 21 | user(id: "${toGlobalId('User', user._id)}") { 22 | _id 23 | name 24 | email 25 | active 26 | } 27 | } 28 | } 29 | `; 30 | 31 | const rootValue = {}; 32 | const context = { }; 33 | 34 | const result = await graphql(schema, query, rootValue, context); 35 | const { viewer } = result.data; 36 | 37 | expect(viewer.user.name).toBe(user.name); 38 | expect(viewer.user.email).toBe(null); // no authenticated user 39 | }); 40 | -------------------------------------------------------------------------------- /server/test/helper.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | import mongoose from 'mongoose'; 3 | 4 | const { ObjectId } = mongoose.Types; 5 | 6 | process.env.NODE_ENV = 'test'; 7 | 8 | const config = { 9 | db: { 10 | test: 'mongodb://localhost/test', 11 | }, 12 | connection: null, 13 | }; 14 | 15 | function connect() { 16 | return new Promise((resolve, reject) => { 17 | if (config.connection) { 18 | return resolve(); 19 | } 20 | 21 | const mongoUri = 'mongodb://localhost/test'; 22 | 23 | mongoose.Promise = Promise; 24 | 25 | const options = { 26 | server: { 27 | auto_reconnect: true, 28 | reconnectTries: Number.MAX_VALUE, 29 | reconnectInterval: 1000, 30 | }, 31 | }; 32 | 33 | mongoose.connect(mongoUri, options); 34 | 35 | config.connection = mongoose.connection; 36 | 37 | config.connection 38 | .once('open', resolve) 39 | .on('error', (e) => { 40 | if (e.message.code === 'ETIMEDOUT') { 41 | console.log(e); 42 | 43 | mongoose.connect(mongoUri, options); 44 | } 45 | 46 | console.log(e); 47 | reject(e); 48 | }); 49 | }); 50 | } 51 | 52 | function clearDatabase() { 53 | return new Promise(resolve => { 54 | for (const i in mongoose.connection.collections) { 55 | mongoose.connection.collections[i].remove(function() {}); 56 | } 57 | 58 | resolve(); 59 | }); 60 | } 61 | 62 | export async function setupTest() { 63 | await connect(); 64 | await clearDatabase(); 65 | } 66 | -------------------------------------------------------------------------------- /server/test/mongooseConnection.js: -------------------------------------------------------------------------------- 1 | import mongoose from 'mongoose'; 2 | 3 | const mongoUri = 'mongodb://localhost/test'; 4 | 5 | // mongoose.set('debug', true); 6 | 7 | mongoose.Promise = Promise; 8 | mongoose.connect(mongoUri, { 9 | server: { 10 | auto_reconnect: true, 11 | reconnectTries: Number.MAX_VALUE, 12 | reconnectInterval: 1000, 13 | }, 14 | }); 15 | 16 | export const connection = mongoose.connection; 17 | 18 | connection.on('error', (e) => { 19 | if (e.message.code === 'ETIMEDOUT') { 20 | console.log(e); 21 | mongoose.connect(mongoUri, opts); 22 | } 23 | console.log(e); 24 | }); 25 | 26 | connection.once('open', () => { 27 | console.log(`MongoDB successfully connected to ${mongoUri}`); 28 | }); 29 | --------------------------------------------------------------------------------