From 91bb4cdb5e6fed37d921e1e50d3611f59cf29855 Mon Sep 17 00:00:00 2001 From: Brian Lovin Date: Sat, 27 Jan 2018 15:48:06 -0800 Subject: [PATCH 1/3] First hotfixes for shared gql --- iris/routes/auth/facebook.js | 22 +++++----- iris/routes/auth/github.js | 22 +++++----- iris/routes/auth/google.js | 22 +++++----- iris/routes/auth/twitter.js | 22 +++++----- iris/utils/create-graphql-error-formatter.js | 1 + iris/utils/is-spectrum-url.js | 6 +-- shared/graphql/schema.json | 45 ++++++++++++++++++++ 7 files changed, 93 insertions(+), 47 deletions(-) diff --git a/iris/routes/auth/facebook.js b/iris/routes/auth/facebook.js index 22b7ca2a95..84ec8bfe8e 100644 --- a/iris/routes/auth/facebook.js +++ b/iris/routes/auth/facebook.js @@ -40,17 +40,17 @@ facebookAuthRouter.get( redirectUrl.searchParams.append('authed', 'true'); // Add the session cookies to the query params if authenticating from mobile - if ( - isExpoUrl(req.session.redirectUrl) && - req.cookies && - req.cookies.session - ) { - redirectUrl.searchParams.append('session', req.cookies.session); - redirectUrl.searchParams.append( - 'session.sig', - req.cookies['session.sig'] - ); - } + // if ( + // isExpoUrl(req.session.redirectUrl) && + // req.cookies && + // req.cookies.session + // ) { + // redirectUrl.searchParams.append('session', req.cookies.session); + // redirectUrl.searchParams.append( + // 'session.sig', + // req.cookies['session.sig'] + // ); + // } // Delete the redirectURL from the session again so we don't redirect // to the old URL the next time around diff --git a/iris/routes/auth/github.js b/iris/routes/auth/github.js index 0c9ddb4150..3d4d948cd6 100644 --- a/iris/routes/auth/github.js +++ b/iris/routes/auth/github.js @@ -40,17 +40,17 @@ githubAuthRouter.get( redirectUrl.searchParams.append('authed', 'true'); // Add the session cookies to the query params if authenticating from mobile - if ( - isExpoUrl(req.session.redirectUrl) && - req.cookies && - req.cookies.session - ) { - redirectUrl.searchParams.append('session', req.cookies.session); - redirectUrl.searchParams.append( - 'session.sig', - req.cookies['session.sig'] - ); - } + // if ( + // isExpoUrl(req.session.redirectUrl) && + // req.cookies && + // req.cookies.session + // ) { + // redirectUrl.searchParams.append('session', req.cookies.session); + // redirectUrl.searchParams.append( + // 'session.sig', + // req.cookies['session.sig'] + // ); + // } // Delete the redirectURL from the session again so we don't redirect // to the old URL the next time around diff --git a/iris/routes/auth/google.js b/iris/routes/auth/google.js index e4e2b33835..f003f4b58b 100644 --- a/iris/routes/auth/google.js +++ b/iris/routes/auth/google.js @@ -45,17 +45,17 @@ googleAuthRouter.get( redirectUrl.searchParams.append('authed', 'true'); // Add the session cookies to the query params if authenticating from mobile - if ( - isExpoUrl(req.session.redirectUrl) && - req.cookies && - req.cookies.session - ) { - redirectUrl.searchParams.append('session', req.cookies.session); - redirectUrl.searchParams.append( - 'session.sig', - req.cookies['session.sig'] - ); - } + // if ( + // isExpoUrl(req.session.redirectUrl) && + // req.cookies && + // req.cookies.session + // ) { + // redirectUrl.searchParams.append('session', req.cookies.session); + // redirectUrl.searchParams.append( + // 'session.sig', + // req.cookies['session.sig'] + // ); + // } // Delete the redirectURL from the session again so we don't redirect // to the old URL the next time around diff --git a/iris/routes/auth/twitter.js b/iris/routes/auth/twitter.js index c080baec64..bd7b2b7a4e 100644 --- a/iris/routes/auth/twitter.js +++ b/iris/routes/auth/twitter.js @@ -40,17 +40,17 @@ twitterAuthRouter.get( redirectUrl.searchParams.append('authed', 'true'); // Add the session cookies to the query params if authenticating from mobile - if ( - isExpoUrl(req.session.redirectUrl) && - req.cookies && - req.cookies.session - ) { - redirectUrl.searchParams.append('session', req.cookies.session); - redirectUrl.searchParams.append( - 'session.sig', - req.cookies['session.sig'] - ); - } + // if ( + // isExpoUrl(req.session.redirectUrl) && + // req.cookies && + // req.cookies.session + // ) { + // redirectUrl.searchParams.append('session', req.cookies.session); + // redirectUrl.searchParams.append( + // 'session.sig', + // req.cookies['session.sig'] + // ); + // } // Delete the redirectURL from the session again so we don't redirect // to the old URL the next time around diff --git a/iris/utils/create-graphql-error-formatter.js b/iris/utils/create-graphql-error-formatter.js index bc142c8745..7e31d5c590 100644 --- a/iris/utils/create-graphql-error-formatter.js +++ b/iris/utils/create-graphql-error-formatter.js @@ -6,6 +6,7 @@ import type { GraphQLError } from 'graphql'; const createGraphQLErrorFormatter = (req?: express$Request) => ( error: GraphQLError ) => { + console.log('error', error); const isUserError = error.originalError ? error.originalError[IsUserError] : false; diff --git a/iris/utils/is-spectrum-url.js b/iris/utils/is-spectrum-url.js index 248067ed5f..923b6a822f 100644 --- a/iris/utils/is-spectrum-url.js +++ b/iris/utils/is-spectrum-url.js @@ -3,16 +3,16 @@ import { URL } from 'url'; import { RELATIVE_URL } from 'shared/regexps'; const IS_PROD = process.env.NODE_ENV === 'production'; -const EXPO_URL = /^https:\/\/auth\.expo\.io\/@(mxstbr|uberbryn|brianlovin)\//; +// const EXPO_URL = /^https:\/\/auth\.expo\.io\/@(mxstbr|uberbryn|brianlovin)\//; -export const isExpoUrl = (url: string): boolean => EXPO_URL.test(url); +// export const isExpoUrl = (url: string): boolean => EXPO_URL.test(url); /** * Make a URL string is a spectrum.chat URL */ export default (url: string): boolean => { if (RELATIVE_URL.test(url)) return true; - if (EXPO_URL.test(url)) return true; + // if (EXPO_URL.test(url)) return true; try { const { hostname } = new URL(url); diff --git a/shared/graphql/schema.json b/shared/graphql/schema.json index 6348eb9dd2..2c533502b4 100644 --- a/shared/graphql/schema.json +++ b/shared/graphql/schema.json @@ -261,6 +261,11 @@ "name": "CommunityChannelEdge", "possibleTypes": null }, + { + "kind": "INPUT_OBJECT", + "name": "MemberConnectionFilter", + "possibleTypes": null + }, { "kind": "OBJECT", "name": "CommunityMembersConnection", @@ -371,6 +376,46 @@ "name": "CoreMetrics", "possibleTypes": null }, + { + "kind": "ENUM", + "name": "SearchType", + "possibleTypes": null + }, + { + "kind": "INPUT_OBJECT", + "name": "SearchFilter", + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "SearchResults", + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "SearchResultsConnection", + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "SearchResultEdge", + "possibleTypes": null + }, + { + "kind": "UNION", + "name": "SearchResultNode", + "possibleTypes": [ + { + "name": "Community" + }, + { + "name": "Thread" + }, + { + "name": "User" + } + ] + }, { "kind": "OBJECT", "name": "Mutation", From 48a6107e79a44e7266d6576814b3f1a3bb90b220 Mon Sep 17 00:00:00 2001 From: Maximilian Stoiber Date: Mon, 29 Jan 2018 19:08:30 +0100 Subject: [PATCH 2/3] Fix shared queries --- .babelrc | 1 - package.json | 1 - 2 files changed, 2 deletions(-) diff --git a/.babelrc b/.babelrc index 29d4ad5bb0..f692f993ee 100644 --- a/.babelrc +++ b/.babelrc @@ -24,7 +24,6 @@ "syntax-async-generators", "transform-async-generator-functions", "react-loadable/babel", - "graphql-tag", "babel-plugin-inline-import-graphql-ast" ] } diff --git a/package.json b/package.json index 09f2081147..01da076b48 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,6 @@ "devDependencies": { "babel-cli": "^6.24.1", "babel-eslint": "^8.0.1", - "babel-plugin-graphql-tag": "^1.3.0", "babel-plugin-import-inspector": "^2.0.0", "babel-plugin-inline-import-graphql-ast": "^2.0.4", "babel-plugin-styled-components": "^1.1.7", From 3a212c0aefe502d19a6d3f895acf1afa9ac7c023 Mon Sep 17 00:00:00 2001 From: Maximilian Stoiber Date: Mon, 29 Jan 2018 19:10:26 +0100 Subject: [PATCH 3/3] Revert "First hotfixes for shared gql" This reverts commit 91bb4cdb5e6fed37d921e1e50d3611f59cf29855. --- iris/routes/auth/facebook.js | 22 +++++----- iris/routes/auth/github.js | 22 +++++----- iris/routes/auth/google.js | 22 +++++----- iris/routes/auth/twitter.js | 22 +++++----- iris/utils/create-graphql-error-formatter.js | 1 - iris/utils/is-spectrum-url.js | 6 +-- shared/graphql/schema.json | 45 -------------------- 7 files changed, 47 insertions(+), 93 deletions(-) diff --git a/iris/routes/auth/facebook.js b/iris/routes/auth/facebook.js index 84ec8bfe8e..22b7ca2a95 100644 --- a/iris/routes/auth/facebook.js +++ b/iris/routes/auth/facebook.js @@ -40,17 +40,17 @@ facebookAuthRouter.get( redirectUrl.searchParams.append('authed', 'true'); // Add the session cookies to the query params if authenticating from mobile - // if ( - // isExpoUrl(req.session.redirectUrl) && - // req.cookies && - // req.cookies.session - // ) { - // redirectUrl.searchParams.append('session', req.cookies.session); - // redirectUrl.searchParams.append( - // 'session.sig', - // req.cookies['session.sig'] - // ); - // } + if ( + isExpoUrl(req.session.redirectUrl) && + req.cookies && + req.cookies.session + ) { + redirectUrl.searchParams.append('session', req.cookies.session); + redirectUrl.searchParams.append( + 'session.sig', + req.cookies['session.sig'] + ); + } // Delete the redirectURL from the session again so we don't redirect // to the old URL the next time around diff --git a/iris/routes/auth/github.js b/iris/routes/auth/github.js index 3d4d948cd6..0c9ddb4150 100644 --- a/iris/routes/auth/github.js +++ b/iris/routes/auth/github.js @@ -40,17 +40,17 @@ githubAuthRouter.get( redirectUrl.searchParams.append('authed', 'true'); // Add the session cookies to the query params if authenticating from mobile - // if ( - // isExpoUrl(req.session.redirectUrl) && - // req.cookies && - // req.cookies.session - // ) { - // redirectUrl.searchParams.append('session', req.cookies.session); - // redirectUrl.searchParams.append( - // 'session.sig', - // req.cookies['session.sig'] - // ); - // } + if ( + isExpoUrl(req.session.redirectUrl) && + req.cookies && + req.cookies.session + ) { + redirectUrl.searchParams.append('session', req.cookies.session); + redirectUrl.searchParams.append( + 'session.sig', + req.cookies['session.sig'] + ); + } // Delete the redirectURL from the session again so we don't redirect // to the old URL the next time around diff --git a/iris/routes/auth/google.js b/iris/routes/auth/google.js index f003f4b58b..e4e2b33835 100644 --- a/iris/routes/auth/google.js +++ b/iris/routes/auth/google.js @@ -45,17 +45,17 @@ googleAuthRouter.get( redirectUrl.searchParams.append('authed', 'true'); // Add the session cookies to the query params if authenticating from mobile - // if ( - // isExpoUrl(req.session.redirectUrl) && - // req.cookies && - // req.cookies.session - // ) { - // redirectUrl.searchParams.append('session', req.cookies.session); - // redirectUrl.searchParams.append( - // 'session.sig', - // req.cookies['session.sig'] - // ); - // } + if ( + isExpoUrl(req.session.redirectUrl) && + req.cookies && + req.cookies.session + ) { + redirectUrl.searchParams.append('session', req.cookies.session); + redirectUrl.searchParams.append( + 'session.sig', + req.cookies['session.sig'] + ); + } // Delete the redirectURL from the session again so we don't redirect // to the old URL the next time around diff --git a/iris/routes/auth/twitter.js b/iris/routes/auth/twitter.js index bd7b2b7a4e..c080baec64 100644 --- a/iris/routes/auth/twitter.js +++ b/iris/routes/auth/twitter.js @@ -40,17 +40,17 @@ twitterAuthRouter.get( redirectUrl.searchParams.append('authed', 'true'); // Add the session cookies to the query params if authenticating from mobile - // if ( - // isExpoUrl(req.session.redirectUrl) && - // req.cookies && - // req.cookies.session - // ) { - // redirectUrl.searchParams.append('session', req.cookies.session); - // redirectUrl.searchParams.append( - // 'session.sig', - // req.cookies['session.sig'] - // ); - // } + if ( + isExpoUrl(req.session.redirectUrl) && + req.cookies && + req.cookies.session + ) { + redirectUrl.searchParams.append('session', req.cookies.session); + redirectUrl.searchParams.append( + 'session.sig', + req.cookies['session.sig'] + ); + } // Delete the redirectURL from the session again so we don't redirect // to the old URL the next time around diff --git a/iris/utils/create-graphql-error-formatter.js b/iris/utils/create-graphql-error-formatter.js index 7e31d5c590..bc142c8745 100644 --- a/iris/utils/create-graphql-error-formatter.js +++ b/iris/utils/create-graphql-error-formatter.js @@ -6,7 +6,6 @@ import type { GraphQLError } from 'graphql'; const createGraphQLErrorFormatter = (req?: express$Request) => ( error: GraphQLError ) => { - console.log('error', error); const isUserError = error.originalError ? error.originalError[IsUserError] : false; diff --git a/iris/utils/is-spectrum-url.js b/iris/utils/is-spectrum-url.js index 923b6a822f..248067ed5f 100644 --- a/iris/utils/is-spectrum-url.js +++ b/iris/utils/is-spectrum-url.js @@ -3,16 +3,16 @@ import { URL } from 'url'; import { RELATIVE_URL } from 'shared/regexps'; const IS_PROD = process.env.NODE_ENV === 'production'; -// const EXPO_URL = /^https:\/\/auth\.expo\.io\/@(mxstbr|uberbryn|brianlovin)\//; +const EXPO_URL = /^https:\/\/auth\.expo\.io\/@(mxstbr|uberbryn|brianlovin)\//; -// export const isExpoUrl = (url: string): boolean => EXPO_URL.test(url); +export const isExpoUrl = (url: string): boolean => EXPO_URL.test(url); /** * Make a URL string is a spectrum.chat URL */ export default (url: string): boolean => { if (RELATIVE_URL.test(url)) return true; - // if (EXPO_URL.test(url)) return true; + if (EXPO_URL.test(url)) return true; try { const { hostname } = new URL(url); diff --git a/shared/graphql/schema.json b/shared/graphql/schema.json index 2c533502b4..6348eb9dd2 100644 --- a/shared/graphql/schema.json +++ b/shared/graphql/schema.json @@ -261,11 +261,6 @@ "name": "CommunityChannelEdge", "possibleTypes": null }, - { - "kind": "INPUT_OBJECT", - "name": "MemberConnectionFilter", - "possibleTypes": null - }, { "kind": "OBJECT", "name": "CommunityMembersConnection", @@ -376,46 +371,6 @@ "name": "CoreMetrics", "possibleTypes": null }, - { - "kind": "ENUM", - "name": "SearchType", - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "SearchFilter", - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "SearchResults", - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "SearchResultsConnection", - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "SearchResultEdge", - "possibleTypes": null - }, - { - "kind": "UNION", - "name": "SearchResultNode", - "possibleTypes": [ - { - "name": "Community" - }, - { - "name": "Thread" - }, - { - "name": "User" - } - ] - }, { "kind": "OBJECT", "name": "Mutation",