Skip to content

Commit 196e9a0

Browse files
dimaMachinaTallTed
andauthored
[v4] some refactoring (#3726)
* some refactoring * use `right: var(--px-16)` instead of `right: 0` for `.graphiql-logo` * more * try to fix * fix join is not defined * Update packages/graphiql/cypress/e2e/incremental-delivery.cy.ts Co-authored-by: Ted Thibodeau Jr <tthibodeau@openlinksw.com> --------- Co-authored-by: Ted Thibodeau Jr <tthibodeau@openlinksw.com>
1 parent f8b719f commit 196e9a0

File tree

9 files changed

+35
-34
lines changed

9 files changed

+35
-34
lines changed

.changeset/strong-ears-bake.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'graphiql': patch
3+
---
4+
5+
use `right: var(--px-16)` instead of `right: 0` for `.graphiql-logo`

packages/graphiql/cypress/e2e/incremental-delivery.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ describeOrSkip('IncrementalDelivery support via fetcher', () => {
105105
This tests that;
106106
1. user ({name}) => { name }
107107
2. user ({age}) => { name, age }
108-
3. user.friends.0 ({name}) => { name, age, friends: [{name}] } <- can sometimes happen before 4, due the the promise race
108+
3. user.friends.0 ({name}) => { name, age, friends: [{name}] } <- can sometimes happen before 4, due to the promise race
109109
4. user.friends.0 ({age}) => { name, age, friends: [{name, age}] }
110110
111111
This shows us that we can deep merge defers, deep merge streams, and also deep merge defers inside streams

packages/graphiql/cypress/e2e/init.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const mockSuccess = {
1515
data: {
1616
longDescriptionType: {
1717
id: 'abc123',
18-
image: '/images/logo.svg',
18+
image: '/resources/logo.svg',
1919
hasArgs: '{"defaultValue":"test default value"}',
2020
test: {
2121
id: 'abc123',

packages/graphiql/cypress/e2e/tabs.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ describe('Tabs', () => {
6161
query: 'query Foo {image}',
6262
variablesString: '{"someVar":42}',
6363
headersString: '{"someHeader":"someValue"}',
64-
response: { data: { image: '/images/logo.svg' } },
64+
response: { data: { image: '/resources/logo.svg' } },
6565
});
6666

6767
// Close tab

packages/graphiql/index.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
5-
<link rel="icon" type="image/svg+xml" href="/test/images/logo.svg" />
5+
<link rel="icon" type="image/svg+xml" href="/resources/logo.svg" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>GraphiQL</title>
88
<style>
99
body {
1010
margin: 0;
11+
overflow: hidden; /* in Firefox */
1112
}
1213

1314
#graphiql {
@@ -25,11 +26,11 @@
2526
<!--vite-replace-start-->
2627
<script
2728
crossorigin
28-
src="https://unpkg.com/react@18/umd/react.development.js"
29+
src="https://unpkg.com/react@18/umd/react.production.min.js"
2930
></script>
3031
<script
3132
crossorigin
32-
src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"
33+
src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"
3334
></script>
3435
<script src="/dist/index.umd.js"></script>
3536
<link href="/dist/style.css" rel="stylesheet" />
Lines changed: 1 addition & 1 deletion
Loading

packages/graphiql/src/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ button.graphiql-tab-add {
8686
/* The GraphiQL logo */
8787
.graphiql-container .graphiql-logo {
8888
position: absolute;
89-
right: 0;
89+
right: var(--px-16);
9090
color: hsla(var(--color-neutral), var(--alpha-secondary));
9191
font-size: var(--font-size-h4);
9292
font-weight: var(--font-weight-medium);

packages/graphiql/test/schema.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,7 @@ const UnionSecond = new GraphQLObjectType({
130130
const TestUnion = new GraphQLUnionType({
131131
name: 'TestUnion',
132132
types: [UnionFirst, UnionSecond],
133-
resolveType() {
134-
return UnionFirst;
135-
},
133+
resolveType: () => UnionFirst,
136134
});
137135

138136
const Greeting = new GraphQLObjectType({
@@ -192,7 +190,7 @@ const Person = new GraphQLObjectType({
192190
friends: {
193191
type: new GraphQLList(Person),
194192
async *resolve(_value, _args) {
195-
const names = ['James', 'Mary', 'John', 'Patrica']; // Top 4 names https://www.ssa.gov/oact/babynames/decades/century.html
193+
const names = ['James', 'Mary', 'John', 'Patrica']; // Top 4 names https://ssa.gov/oact/babynames/decades/century.html
196194
for (const name of names) {
197195
await sleep(100);
198196
yield { name };
@@ -202,14 +200,15 @@ const Person = new GraphQLObjectType({
202200
}),
203201
});
204202

205-
const sleep = async timeout => new Promise(res => setTimeout(res, timeout));
203+
const sleep = async timeout =>
204+
new Promise(resolve => setTimeout(resolve, timeout));
206205

207206
const longDescription = `
208207
The \`longDescriptionType\` field on the \`Test\` type has a long, verbose, description to test inline field docs.
209208
210209
> We want to test several \`markdown\` styles!
211210
212-
Check out [Markdown](https://www.markdownguide.org/) by the way.
211+
Check out [Markdown](https://markdownguide.org) by the way.
213212
214213
Some notes:
215214
- Lists
@@ -218,14 +217,14 @@ Some notes:
218217
- and with very very very very very very very very very very long items that span multiple lines
219218
- you get the gist
220219
221-
To-Do's:
220+
TO-DO's:
222221
1. Open GraphiQL
223-
2. Write a query
222+
1. Write a query
224223
1. Maybe add some variables
225-
2. Could also add headers
226-
3. Send the request
224+
1. Could also add headers
225+
1. Send the request
227226
228-
Example quey:
227+
Example query:
229228
\`\`\`graphql
230229
{
231230
test {
@@ -237,7 +236,7 @@ Example quey:
237236
238237
And we have a cool logo:
239238
240-
![](/images/logo.svg)
239+
![](/resources/logo.svg)
241240
`.trim();
242241

243242
const TestType = new GraphQLObjectType({
@@ -306,7 +305,7 @@ const TestType = new GraphQLObjectType({
306305
image: {
307306
type: GraphQLString,
308307
description: 'field that returns an image URI.',
309-
resolve: () => '/images/logo.svg',
308+
resolve: () => '/resources/logo.svg',
310309
},
311310
deprecatedField: {
312311
type: TestType,
@@ -371,7 +370,7 @@ const TestMutationType = new GraphQLObjectType({
371370
const TestSubscriptionType = new GraphQLObjectType({
372371
name: 'SubscriptionType',
373372
description:
374-
'This is a simple subscription type. Learn more at https://www.npmjs.com/package/graphql-ws',
373+
'This is a simple subscription type. Learn more at https://npmjs.com/package/graphql-ws',
375374
fields: {
376375
message: {
377376
type: GraphQLString,

packages/graphql-language-service-server/src/__tests__/MessageProcessor.spec.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import mockfs from 'mock-fs';
2-
import { join } from 'node:path';
32
import { MockFile, MockProject } from './__utils__/MockProject';
43
import { FileChangeType } from 'vscode-languageserver';
54
import { serializeRange } from './__utils__/utils';
@@ -30,9 +29,7 @@ jest.mock('@whatwg-node/fetch', () => {
3029

3130
const mockSchema = (schema: GraphQLSchema) => {
3231
const introspectionResult = {
33-
data: introspectionFromSchema(schema, {
34-
descriptions: true,
35-
}),
32+
data: introspectionFromSchema(schema, { descriptions: true }),
3633
};
3734
return fetchMock.mock({
3835
matcher: '*',
@@ -45,10 +42,10 @@ const mockSchema = (schema: GraphQLSchema) => {
4542
});
4643
};
4744

48-
const defaultFiles = [
45+
const defaultFiles: MockFile[] = [
4946
['query.graphql', 'query { bar ...B }'],
5047
['fragments.graphql', 'fragment B on Foo { bar }'],
51-
] as MockFile[];
48+
];
5249
const schemaFile: MockFile = [
5350
'schema.graphql',
5451
'type Query { foo: Foo, test: Test }\n\ntype Foo { bar: String }\n\ntype Test { test: Foo }',
@@ -290,7 +287,7 @@ describe('MessageProcessor with config', () => {
290287
expect(result.diagnostics[0].message).toEqual(
291288
'Cannot query field "bar" on type "Foo". Did you mean "bad"?',
292289
);
293-
const generatedFile = existsSync(join(genSchemaPath));
290+
const generatedFile = existsSync(genSchemaPath);
294291
// this generated file should not exist because the schema is local!
295292
expect(generatedFile).toEqual(false);
296293
// simulating codegen
@@ -391,7 +388,7 @@ describe('MessageProcessor with config', () => {
391388
expect(await project.lsp._graphQLCache.getSchema('default')).toBeDefined();
392389

393390
// schema file is present and contains schema
394-
const file = await readFile(join(genSchemaPath), { encoding: 'utf-8' });
391+
const file = await readFile(genSchemaPath, 'utf8');
395392
expect(file.split('\n').length).toBeGreaterThan(10);
396393

397394
// hover works
@@ -406,9 +403,10 @@ describe('MessageProcessor with config', () => {
406403

407404
// ensure that fragment definitions work
408405
const definitions = await project.lsp.handleDefinitionRequest({
409-
textDocument: { uri: project.uri('query.graphql') }, // console.log(project.uri('query.graphql'))
406+
textDocument: { uri: project.uri('query.graphql') },
410407
position: { character: 26, line: 0 },
411408
});
409+
412410
expect(definitions[0].uri).toEqual(project.uri('fragments.graphql'));
413411
expect(serializeRange(definitions[0].range)).toEqual({
414412
start: {
@@ -559,9 +557,7 @@ describe('MessageProcessor with config', () => {
559557
(await project.lsp._graphQLCache.getSchema('a')).getType('example100'),
560558
).toBeTruthy();
561559
await sleep(1000);
562-
const file = await readFile(join(genSchemaPath.replace('default', 'a')), {
563-
encoding: 'utf-8',
564-
});
560+
const file = await readFile(genSchemaPath.replace('default', 'a'), 'utf8');
565561
expect(file).toContain('example100');
566562
// add a new typescript file with empty query to the b project
567563
// and expect autocomplete to only show options for project b

0 commit comments

Comments
 (0)