Skip to content

Commit 5a7c088

Browse files
committed
fix: graphql export
1 parent 9f696fe commit 5a7c088

File tree

4 files changed

+100
-2
lines changed

4 files changed

+100
-2
lines changed

src/apitypes/graphql/graphql.document.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,11 @@ export const buildGraphQLDocument: DocumentBuilder<GraphApiSchema> = async (pars
5252
}
5353

5454
export const dumpGraphQLDocument: DocumentDumper<GraphApiSchema> = (document) => {
55-
return new Blob([printGraphApi(document.data)], { type: 'text/plain' })
55+
if (document.data) {
56+
return new Blob([printGraphApi(document.data)], { type: 'text/plain' })
57+
}
58+
if (document.source) {
59+
return document.source
60+
}
61+
throw new Error(`Document ${document.fileId} has neither data nor source`)
5662
}

test/helpers/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
import { buildSchema, introspectionFromSchema } from 'graphql/utilities'
3131
import { LocalRegistry } from './registry'
3232
import { Editor } from './editor'
33+
import { getFileExtension } from '../../src/utils'
3334

3435
export const loadFileAsString = async (filePath: string, folder: string, fileName: string): Promise<string | null> => {
3536
return (await loadFile(filePath, folder, fileName))?.text() ?? null
@@ -38,7 +39,7 @@ export const loadFileAsString = async (filePath: string, folder: string, fileNam
3839
export const loadFile = async (filePath: string, folder: string, fileName: string): Promise<File | null> => {
3940
try {
4041
const filepath = path.join(process.cwd(), filePath, folder, fileName)
41-
const mediaType = mime.lookup(filepath)
42+
const mediaType = mime.lookup(fileName) || (['graphql', 'gql'].includes(getFileExtension(fileName)) ? 'text/plain' : false)
4243
if (!mediaType) {
4344
console.error('Can\'t lookup the media type')
4445
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#All Directives
2+
3+
directive @deprecated( reason: String = "No longer supported" ) on OBJECT | INPUT_OBJECT | FIELD_DEFINITION | INPUT_FIELD_DEFINITION | ARGUMENT_DEFINITION | UNION | ENUM_VALUE
4+
5+
type Query
6+
{
7+
"""Get list of Pets"""
8+
listPets(listId: String):[Pet!]
9+
10+
"""Get Pet by ID"""
11+
getPet(id: String!): Pet
12+
13+
"""Get list of Users"""
14+
listUsers(listId: String):[User!]
15+
16+
"""Get User by ID"""
17+
getUser(id: String!): User @deprecated (reason: "New query is developed")
18+
}
19+
20+
type Mutation {
21+
"""Pet availability check"""
22+
petAvailabilityCheck(input: AvailabilityCheckRequest): [AvailabilityCheckResult!]
23+
}
24+
25+
"""Availability Check Request"""
26+
input AvailabilityCheckRequest {
27+
28+
"""Pet Unique identifiers"""
29+
petId: [String!]
30+
}
31+
32+
"""Availability Check Result"""
33+
type AvailabilityCheckResult {
34+
"""Pet Unique identifier"""
35+
petId: String
36+
37+
"""Result of the availability check"""
38+
availabilityCheckResult: String
39+
40+
"""Availability check message"""
41+
availabilityCheckResultMessage: String
42+
}
43+
44+
"""The entity represents a Pet"""
45+
type Pet {
46+
"""Unique identifier"""
47+
id: String
48+
49+
"""Name"""
50+
name: String
51+
52+
"""Category"""
53+
category: Category
54+
55+
""" Status """
56+
status: String
57+
58+
"""Age"""
59+
age: String @deprecated (reason: "To be deleted")
60+
}
61+
62+
"""The entity represents a Category"""
63+
type Category {
64+
"""Unique identifier"""
65+
id: String
66+
67+
"""Name"""
68+
name: String
69+
}
70+
71+
"""The entity represents a User"""
72+
type User {
73+
74+
"""Unique identifier"""
75+
id: String
76+
77+
"""Name"""
78+
username: String
79+
80+
"""First name"""
81+
firstName: String
82+
83+
"""Last name"""
84+
lastName: String
85+
}

test/projects/export/config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
"labels": [],
1717
"commitId": "6c778b1f44200bd19944a6a8eac10a4e5a21a3cd"
1818
},
19+
{
20+
"fileId": "atui_graphql_changelog_base.graphql",
21+
"publish": true,
22+
"labels": [],
23+
"commitId": "sc778b1f44200bd19944a6a8eac10a4e5d21a3cr"
24+
},
1925
{
2026
"fileId": "Document.docx",
2127
"publish": true,

0 commit comments

Comments
 (0)