forked from cypress-io/cypress
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add graphql to unified-desktop branch (cypress-io#17305)
* refactor: use getPathToDesktopIndex for launchpad path * chore: add dependencies for graphql * Get GraphQL & Vue working together * update vue and remove need for patch-package * add apollo example * Update Wizard.vue * Add prebuild * update types * update tests * use debug instead of console.log * skip test * close gql server * fix server unit tests * try changing policies * try to install angular via package.json injection * update command * move graphql-codegen to dependencies * update package.json * bump deps * add gql * update build * add codegen.yml to build * add schema to build * include src for launchpad Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com>
- Loading branch information
1 parent
1a9f123
commit 1550733
Showing
35 changed files
with
1,947 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* eslint-disable no-console */ | ||
const fs = require('fs') | ||
const execa = require('execa') | ||
|
||
async function main () { | ||
try { | ||
const pkg = require('./package.json') | ||
|
||
console.log('Adding @angular/cli to package.json') | ||
pkg['devDependencies']['@angular/cli'] = '11.2.12' | ||
fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2)) | ||
|
||
console.log('Running yarn install') | ||
await execa('yarn', ['install'], { stdout: 'inherit' }) | ||
} catch (e) { | ||
if (e.stdout) { | ||
console.error(e.stdout) | ||
} | ||
|
||
const exitCode = e.exitCode ? e.exitCode : 1 | ||
|
||
console.error(`Failed to add @angular/cli with exit code ${exitCode}`) | ||
process.exit(exitCode) | ||
} | ||
} | ||
|
||
// execute main function if called from command line | ||
if (require.main === module) { | ||
main() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
overwrite: true | ||
schema: '../server/schema.graphql' | ||
documents: 'src/**/*.vue' | ||
generates: | ||
src/generated/graphql.tsx: | ||
config: | ||
immutableTypes: true | ||
useTypeImports: true | ||
preResolveTypes: true | ||
onlyOperationTypes: true | ||
avoidOptionals: true | ||
enumsAsTypes: true | ||
plugins: | ||
- 'typescript' | ||
- 'typescript-operations' | ||
- 'typed-document-node' | ||
hooks: | ||
afterOneFileWrite: | ||
- eslint --fix |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
process.env.GRAPHQL_CODEGEN = 'true' | ||
require('@packages/ts/register') | ||
require('../../server/lib/graphql/schema') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ApolloLink, FetchResult, ApolloClient, InMemoryCache, Observable } from '@apollo/client/core' | ||
import { fetchGraphql } from './graphqlIpc' | ||
|
||
const ipcLink = new ApolloLink((op) => { | ||
return new Observable((obs) => { | ||
fetchGraphql(op).then((result) => { | ||
obs.next(result as FetchResult) | ||
obs.complete() | ||
|
||
return result | ||
}).catch((err) => { | ||
obs.error(err) | ||
obs.complete() | ||
}) | ||
}) | ||
}) | ||
|
||
// Cache implementation | ||
const cache = new InMemoryCache() | ||
|
||
// Create the apollo client | ||
export const apolloClient = new ApolloClient({ | ||
link: ipcLink, | ||
cache, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import pDefer from 'p-defer' | ||
import type { Operation } from '@apollo/client' | ||
import { print } from 'graphql' | ||
|
||
export const ipcInFlight = new Map<string, pDefer.DeferredPromise<any>>() | ||
|
||
interface GraphQLResponseShape { | ||
id: string | ||
result: any | ||
} | ||
|
||
// @ts-expect-error | ||
ipc.on('graphql:response', (event, obj: GraphQLResponseShape) => { | ||
const dfd = ipcInFlight.get(obj.id) | ||
|
||
if (!dfd) { | ||
throw new Error('Missing ipcInFlight') | ||
} | ||
|
||
if (obj.result.errors) { | ||
// console.log(obj.result) | ||
} | ||
|
||
dfd.resolve(obj.result) | ||
}) | ||
|
||
// Relay passes a "params" object with the query name and text. So we define | ||
// a helper function to call our fetchGraphQL utility with params.text | ||
export const fetchGraphql = async function fetchGraphql ( | ||
op: Operation, | ||
) { | ||
const dfd = pDefer() | ||
const ipcId = Math.random().toString() | ||
|
||
dfd.promise.finally(() => { | ||
ipcInFlight.delete(ipcId) | ||
}) | ||
|
||
ipcInFlight.set(ipcId, dfd) | ||
|
||
// @ts-expect-error | ||
ipc.send('graphql', { | ||
id: ipcId, | ||
params: { | ||
text: print(op.query), | ||
name: op.operationName, | ||
}, | ||
variables: op.variables, | ||
}) | ||
|
||
return dfd.promise | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.