Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nuxt-backend-helper
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王曜嵚 Wang Yaoqin
nuxt-backend-helper
Commits
e8dd0641
Commit
e8dd0641
authored
Jul 02, 2024
by
王曜嵚 Wang Yaoqin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apollo demo
parent
49140e33
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
1152 additions
and
0 deletions
+1152
-0
ProjectV2.vue
components/ProjectV2.vue
+7
-0
package-lock.json
package-lock.json
+1029
-0
package.json
package.json
+2
-0
query.ts
public/apollo/resolvers/query.ts
+13
-0
query.graphql
public/apollo/typeDefs/query.graphql
+5
-0
user.graphql
public/apollo/typeDefs/user.graphql
+4
-0
v1.graphql
public/apollo/typeDefs/v1.graphql
+5
-0
v2.graphql
public/apollo/typeDefs/v2.graphql
+25
-0
apollo.server.ts
server/plugins/apollo.server.ts
+62
-0
No files found.
components/ProjectV2.vue
View file @
e8dd0641
...
...
@@ -35,6 +35,10 @@
<svg
t=
"1714466881817"
class=
"icon"
viewBox=
"0 0 1024 1024"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
p-id=
"16209"
width=
"200"
height=
"200"
><path
d=
"M966.208 246.752L534.144 21.408a47.968 47.968 0 0 0-44.128-0.128L58.08 243.136A47.968 47.968 0 0 0 32 285.824V744.64c0 18.208 10.304 34.848 26.592 42.976l432 215.36a48 48 0 0 0 42.816 0l432-215.36A48 48 0 0 0 992 744.672V289.344c0-17.92-9.952-34.304-25.792-42.592zM508.384 463.68l-162.176-79.808 367.36-196.704 158.4 82.624-363.584 193.888z m3.488-381.696l132.992 69.376-369.312 197.76-144.896-71.328 381.216-195.808zM96 332.096l153.216 75.392v168.256a32 32 0 0 0 64 0v-136.736L480 521.024v405.184L96 734.752V332.096z m448 594.112V517.184l384-204.736v422.304l-384 191.456z"
p-id=
"16210"
></path></svg>
打包微信压缩文件
</div>
<div
class=
"extra-operation"
@
click=
"handleTest"
>
<svg
t=
"1714466881817"
class=
"icon"
viewBox=
"0 0 1024 1024"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
p-id=
"16209"
width=
"200"
height=
"200"
><path
d=
"M966.208 246.752L534.144 21.408a47.968 47.968 0 0 0-44.128-0.128L58.08 243.136A47.968 47.968 0 0 0 32 285.824V744.64c0 18.208 10.304 34.848 26.592 42.976l432 215.36a48 48 0 0 0 42.816 0l432-215.36A48 48 0 0 0 992 744.672V289.344c0-17.92-9.952-34.304-25.792-42.592zM508.384 463.68l-162.176-79.808 367.36-196.704 158.4 82.624-363.584 193.888z m3.488-381.696l132.992 69.376-369.312 197.76-144.896-71.328 381.216-195.808zM96 332.096l153.216 75.392v168.256a32 32 0 0 0 64 0v-136.736L480 521.024v405.184L96 734.752V332.096z m448 594.112V517.184l384-204.736v422.304l-384 191.456z"
p-id=
"16210"
></path></svg>
测试
</div>
</div>
</div>
</div>
...
...
@@ -139,6 +143,9 @@ async function handleInstall() {
await
$fetch
(
'/api/devops/v2/install'
,
{
method
:
'post'
})
execute
()
}
async
function
handleTest
()
{
await
$fetch
(
'/graphql'
)
}
function
getTip
(
status
:
string
)
{
const
HOST
=
useRuntimeConfig
().
public
.
dockerHost
...
...
package-lock.json
View file @
e8dd0641
This diff is collapsed.
Click to expand it.
package.json
View file @
e8dd0641
...
...
@@ -10,9 +10,11 @@
"postinstall"
:
"nuxt prepare"
},
"dependencies"
:
{
"
@apollo/server
"
:
"
^4.10.4
"
,
"
@pinia/nuxt
"
:
"
^0.5.1
"
,
"
dockerode
"
:
"
^3.3.5
"
,
"
engine.io
"
:
"
^6.5.4
"
,
"
graphql
"
:
"
^16.9.0
"
,
"
lodash
"
:
"
^4.17.21
"
,
"
nuxt
"
:
"
^3.11.1
"
,
"
pg
"
:
"
^8.11.5
"
,
...
...
public/apollo/resolvers/query.ts
0 → 100644
View file @
e8dd0641
export
default
{
Query
:
{
user
:
async
(
parent
:
any
,
args
:
Record
<
string
,
any
>
,
contextValue
:
Record
<
string
,
any
>
,
info
:
Record
<
string
,
any
>
)
=>
{
return
await
getPgTableData
(
'user'
,
args
.
username
)
},
v2
:
async
(
parent
:
any
,
args
:
Record
<
string
,
any
>
,
contextValue
:
Record
<
string
,
any
>
,
info
:
Record
<
string
,
any
>
)
=>
{
return
await
getPgTableData
(
'v2'
,
args
.
username
)
},
v1
:
async
(
parent
:
any
,
args
:
Record
<
string
,
any
>
,
contextValue
:
Record
<
string
,
any
>
,
info
:
Record
<
string
,
any
>
)
=>
{
return
await
getPgTableData
(
'v1'
,
args
.
username
)
}
}
}
\ No newline at end of file
public/apollo/typeDefs/query.graphql
0 → 100644
View file @
e8dd0641
type
Query
{
user
(
username
:
String
):
User
v2
(
username
:
String
):
V2
v1
(
username
:
String
):
V1
}
\ No newline at end of file
public/apollo/typeDefs/user.graphql
0 → 100644
View file @
e8dd0641
type
User
{
username
:
String
port
:
Int
}
\ No newline at end of file
public/apollo/typeDefs/v1.graphql
0 → 100644
View file @
e8dd0641
type
V1
{
username
:
String
status
:
String
serverProperties
:
[
ServerProperty
]!
}
\ No newline at end of file
public/apollo/typeDefs/v2.graphql
0 → 100644
View file @
e8dd0641
type
V2
{
username
:
String
tenants
:
Tenant
debug
:
Debug
has_debugged
:
Boolean
status
:
String
serverProperties
:
[
ServerProperty
]!
}
type
Tenant
{
id
:
String
host
:
String
databaseschema
:
String
primarynamespace
:
String
}
type
Debug
{
host
:
String
}
type
ServerProperty
{
id
:
Float
key
:
String
value
:
String
}
\ No newline at end of file
server/plugins/apollo.server.ts
0 → 100644
View file @
e8dd0641
import
type
{
NitroApp
}
from
"nitropack"
;
import
{
ApolloServer
,
HeaderMap
}
from
'@apollo/server'
import
{
startStandaloneServer
}
from
"@apollo/server/standalone"
;
import
Resolvers
from
'../../public/apollo/resolvers/query'
import
fs
from
'fs'
function
readGraphqlString
(
filename
:
string
)
{
const
path
=
'./public/apollo/typeDefs/'
+
filename
+
'.graphql'
return
fs
.
readFileSync
(
path
,
{
encoding
:
'utf-8'
})
}
export
default
defineNitroPlugin
((
nitroApp
:
NitroApp
)
=>
{
const
resolvers
=
Resolvers
const
query
=
readGraphqlString
(
'query'
)
const
user
=
readGraphqlString
(
'user'
)
const
v2
=
readGraphqlString
(
'v2'
)
const
v1
=
readGraphqlString
(
'v1'
)
const
typeDefs
=
`
${
query
}
${
user
}
${
v2
}
${
v1
}
`
const
server
=
new
ApolloServer
({
typeDefs
,
resolvers
})
startStandaloneServer
(
server
).
then
(()
=>
{
console
.
log
(
'apollo started'
)
})
nitroApp
.
router
.
use
(
'/graphql'
,
defineEventHandler
({
handler
(
event
)
{
console
.
log
(
'in graphql'
)
const
headers
=
new
HeaderMap
();
for
(
const
[
key
,
value
]
of
Object
.
entries
(
event
.
headers
))
{
if
(
value
!==
undefined
)
{
headers
.
set
(
key
,
Array
.
isArray
(
value
)
?
value
.
join
(
', '
)
:
value
);
}
}
return
server
.
executeHTTPGraphQLRequest
({
httpGraphQLRequest
:
{
method
:
'get'
,
headers
,
search
:
`query{
user
}`
,
body
:
{
username
:
'wyq'
}
},
context
:
()
=>
{
return
Promise
.
resolve
({})
}
}).
then
((
value
)
=>
{
console
.
log
(
'success'
,
value
)
return
value
}).
catch
(
err
=>
{
console
.
log
(
'err'
,
err
)
})
}
}))
})
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment