Skip to content

Commit

Permalink
fix: Remove Apollo warning about cache (#558)
Browse files Browse the repository at this point in the history
* fix: Remove Apollo warning about cache

* Update Apollo Client

* Lint all files

* Regenerate yarn
  • Loading branch information
amaury1093 committed Apr 24, 2020
1 parent 668213e commit f42d3a0
Show file tree
Hide file tree
Showing 10 changed files with 438 additions and 353 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
brew install applesimutils
- run: yarn install
- name: Generate staging app.json
run: ./scripts/generateAppJson.js
run: ./scripts/generateAppJson.js > app.json
- name: Download ExpoClient binary
run: ./e2e/dl_expo_bins.sh
- name: Run E2E Tests
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
env:
SIS_AQICN_TOKEN: ${{ secrets.SIS_PRODUCTION_AQICN_TOKEN }}
SIS_AMPLITUDE_API_KEY: ${{ secrets.SIS_PRODUCTION_AMPLITUDE_API_KEY }}
SIS_BACKEND_URL: https://shootismoke.now.sh/api/graphql
SIS_HAWK_KEY: ${{ secrets.SIS_PRODUCTION_HAWK_KEY }}
SIS_SENTRY_PUBLIC_DNS: ${{ secrets.SIS_PRODUCTION_SENTRY_PUBLIC_DNS }}
SIS_SENTRY_ORG: ${{ secrets.SIS_PRODUCTION_SENTRY_ORG }}
Expand Down Expand Up @@ -55,5 +56,5 @@ jobs:
if: startsWith(github.ref, 'refs/tags/v')
run: echo ::set-env name=RELEASE_CHANNEL::${GITHUB_REF:10} # Remove refs/tags/
- name: Generate production app.json
run: ./scripts/generateAppJson.js
run: ./scripts/generateAppJson.js > app.json
- run: expo ${{ matrix.expo_build_command }} --release-channel=production-${{ env.RELEASE_CHANNEL }}
2 changes: 1 addition & 1 deletion .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ jobs:
expo-cache: true
- run: yarn install
- name: Generate staging app.json
run: ./scripts/generateAppJson.js
run: ./scripts/generateAppJson.js > app.json
- run: expo publish
10 changes: 4 additions & 6 deletions App/stores/apollo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { persistCache } from 'apollo-cache-persist';
import Constants from 'expo-constants';
import { AsyncStorage } from 'react-native';

import { IS_PROD } from '../util/constants';
import { sentryError } from '../util/sentry';
import {
credentials,
Expand All @@ -36,10 +35,6 @@ import {
hawkFetch,
} from './util';

const BACKEND_URI = IS_PROD
? 'https://shootismoke.now.sh/api/graphql'
: 'https://staging.shootismoke.now.sh/api/graphql';

// FIXME Which type should this have?
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type TCacheShape = any;
Expand Down Expand Up @@ -106,7 +101,10 @@ export async function getApolloClient(): Promise<ApolloClient<TCacheShape>> {
// Retry on error
new RetryLink(),
// Classic HTTP link
createHttpLink({ fetch: hawkFetch(BACKEND_URI), uri: BACKEND_URI }),
createHttpLink({
fetch: hawkFetch(Constants.manifest.extra.backendUrl),
uri: Constants.manifest.extra.backendUrl,
}),
]),
name: 'shootismoke-expo',
typeDefs: [userSchema],
Expand Down
3 changes: 0 additions & 3 deletions App/stores/util/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ type DeepPartial<T> = {

const GET_USER = gql`
query getUser($expoInstallationId: ID!) {
__typename
getUser(expoInstallationId: $expoInstallationId) {
__typename
_id
Expand All @@ -63,7 +62,6 @@ const GET_USER = gql`

const CREATE_USER = gql`
mutation createUser($input: CreateUserInput!) {
__typename
createUser(input: $input) {
__typename
_id
Expand All @@ -78,7 +76,6 @@ const CREATE_USER = gql`

const UPDATE_USER = gql`
mutation updateUser($expoInstallationId: ID!, $input: UpdateUserInput!) {
__typename
updateUser(expoInstallationId: $expoInstallationId, input: $input) {
__typename
_id
Expand Down
9 changes: 3 additions & 6 deletions app.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@
},
"icon": "assets/logos/android/playstore-icon.png",
"package": "com.shitismoke.app",
"permissions": [
"ACCESS_FINE_LOCATION"
],
"permissions": ["ACCESS_FINE_LOCATION"],
"versionCode": 13
},
"assetBundlePatterns": [
"assets/**/*"
],
"assetBundlePatterns": ["assets/**/*"],
"backgroundColor": "#FAFAFC",
"extra": {
"aqicnToken": "6bb4237574756ba29f05cea553bd22576596c11e",
"amplitudeApiKey": null,
"backendUrl": "https://staging.shootismoke.now.sh/api/graphql",
"hawkKey": "26bb8794-8f1e-4bf7-b977-081186af58d6",
"sentryPublicDsn": null
},
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"main": "node_modules/expo/AppEntry.js",
"private": true,
"scripts": {
"lint": "tsc --noEmit --skipLibCheck && eslint --ext .ts,.tsx App",
"lint": "tsc --noEmit && eslint --ext .js,.ts,.tsx .",
"start": "expo start",
"test:e2e": "detox test --configuration ios.sim --record-videos all"
},
Expand All @@ -23,7 +23,7 @@
"test-runner": "jest"
},
"dependencies": {
"@apollo/client": "^3.0.0-beta.43",
"@apollo/client": "^3.0.0-beta.44",
"@apollo/link-error": "^2.0.0-beta.3",
"@apollo/link-retry": "^2.0.0-beta.3",
"@apollo/react-hooks": "^3.1.5",
Expand Down
30 changes: 16 additions & 14 deletions scripts/generateAppJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,28 @@

/* eslint-disable @typescript-eslint/no-var-requires */

const jsonfile = require('jsonfile');
const merge = require('lodash/merge');

const defaultAppJson = require('../app.example.json');
const pkgJson = require('../package.json');

const STAGING_BACKEND_URL = 'https://staging.shootismoke.now.sh/api/graphql';

const overrides = {
expo: {
android: {
config: {
googleMaps: {
apiKey: process.env.SIS_ANDROID_GOOGLE_MAPS_KEY
}
}
apiKey: process.env.SIS_ANDROID_GOOGLE_MAPS_KEY,
},
},
},
extra: {
aqicnToken: process.env.SIS_AQICN_TOKEN,
amplitudeApiKey: process.env.SIS_AMPLITUDE_API_KEY || null,
backendUrl: process.env.BACKEND_URL || STAGING_BACKEND_URL,
hawkKey: process.env.SIS_HAWK_KEY,
sentryPublicDsn: process.env.SIS_SENTRY_PUBLIC_DNS || null
sentryPublicDsn: process.env.SIS_SENTRY_PUBLIC_DNS || null,
},
hooks: {
postPublish: [
Expand All @@ -36,19 +38,19 @@ const overrides = {
config: {
organization: process.env.SIS_SENTRY_ORG || null,
project: process.env.SIS_SENTRY_PROJECT || null,
authToken: process.env.SIS_SENTRY_AUTH_TOKEN || null
}
}
]
authToken: process.env.SIS_SENTRY_AUTH_TOKEN || null,
},
},
],
},
ios: {
buildNumber: pkgJson.version,
config: {
googleMapsApiKey: process.env.SIS_IOS_GOOGLE_MAPS_KEY
}
googleMapsApiKey: process.env.SIS_IOS_GOOGLE_MAPS_KEY,
},
},
version: pkgJson.version
}
version: pkgJson.version,
},
};

jsonfile.writeFileSync('app.json', merge(defaultAppJson, overrides));
console.log(JSON.stringify(merge(defaultAppJson, overrides)));
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"module": "es6",
"moduleResolution": "node",
"noEmit": true,
"skipLibCheck": true,
"target": "esnext"
},
"exclude": ["node_modules"],
Expand Down
Loading

0 comments on commit f42d3a0

Please sign in to comment.