Skip to content

Commit

Permalink
chore(server): add NLS layer support (#632)
Browse files Browse the repository at this point in the history
Co-authored-by: YK <[email protected]>
  • Loading branch information
pyshx and yk-eukarya authored Aug 28, 2023
1 parent 383ef9b commit c832483
Show file tree
Hide file tree
Showing 40 changed files with 5,809 additions and 444 deletions.
156 changes: 156 additions & 0 deletions server/e2e/gql_nlslayer_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
package e2e

// import (
// "net/http"
// "testing"

// "github.com/gavv/httpexpect/v2"
// "github.com/reearth/reearth/server/internal/app/config"
// )

// func addNLSLayerSimple(e *httpexpect.Expect, sId string) (GraphQLRequest, *httpexpect.Value, string) {
// requestBody := GraphQLRequest{
// OperationName: "addNLSLayerSimple",
// Query: `mutation AddNLSLayerSimple($input: AddNLSLayerSimpleInput!) {
// addNLSLayerSimple(input: $input) {
// layers {
// id
// __typename
// }
// __typename
// }
// }`,
// Variables: map[string]any{
// "input": map[string]any{
// "parentLayerId": "parent12345",
// "layerType": "SimpleType",
// "sceneID": sId,
// "config": map[string]any{
// "data": map[string]any{
// "type": "ExampleType",
// "url": "https://example.com/data",
// "value": "sampleValue",
// "layers": "sampleLayerData",
// "jsonProperties": []string{"prop1", "prop2"},
// "updateInterval": 10,
// "parameters": map[string]any{
// "sampleKey": "sampleValue",
// },
// "time": map[string]any{
// "property": "time",
// "interval": 5,
// "updateClockOnLoad": true,
// },
// "csv": map[string]any{
// "idColumn": "id",
// "latColumn": "latitude",
// "lngColumn": "longitude",
// "heightColumn": "height",
// "noHeader": false,
// "disableTypeConversion": true,
// },
// },
// "properties": "sampleProperties",
// "defines": map[string]string{
// "defineKey": "defineValue",
// },
// "events": "sampleEvents",
// },
// "index": 0,
// },
// },
// }

// res := e.POST("/api/graphql").
// WithHeader("Origin", "https://example.com").
// WithHeader("X-Reearth-Debug-User", uID.String()).
// WithHeader("Content-Type", "application/json").
// WithJSON(requestBody).
// Expect().
// Status(http.StatusOK).
// JSON()

// layerId := res.Path("$.data.addNLSLayerSimple.layers.id").Raw().(string)
// return requestBody, res, layerId
// }

// func removeNLSLayer(e *httpexpect.Expect, layerId string) (GraphQLRequest, *httpexpect.Value) {
// requestBody := GraphQLRequest{
// OperationName: "removeNLSLayer",
// Query: `mutation RemoveNLSLayer($input: RemoveNLSLayerInput!) {
// removeNLSLayer(input: $input) {
// layerId
// }
// }`,
// Variables: map[string]any{
// "input": map[string]any{
// "layerId": layerId,
// },
// },
// }

// res := e.POST("/api/graphql").
// WithHeader("Origin", "https://example.com").
// WithHeader("X-Reearth-Debug-User", uID.String()).
// WithHeader("Content-Type", "application/json").
// WithJSON(requestBody).
// Expect().
// Status(http.StatusOK).
// JSON()

// return requestBody, res
// }

// func updateNLSLayer(e *httpexpect.Expect, layerId string) (GraphQLRequest, *httpexpect.Value) {
// requestBody := GraphQLRequest{
// OperationName: "updateNLSLayer",
// Query: `mutation UpdateNLSLayer($input: UpdateNLSLayerInput!) {
// updateNLSLayer(input: $input) {
// layer {
// id
// __typename
// }
// __typename
// }
// }`,
// Variables: map[string]any{
// "input": map[string]any{
// "layerId": layerId,
// "name": "Updated Layer",
// "visible": true,
// },
// },
// }

// res := e.POST("/api/graphql").
// WithHeader("Origin", "https://example.com").
// WithHeader("X-Reearth-Debug-User", uID.String()).
// WithHeader("Content-Type", "application/json").
// WithJSON(requestBody).
// Expect().
// Status(http.StatusOK).
// JSON()

// return requestBody, res
// }

// func TestNLSLayerCRUD(t *testing.T) {
// e := StartServer(t, &config.Config{
// Origins: []string{"https://example.com"},
// AuthSrv: config.AuthSrvConfig{
// Disabled: true,
// },
// }, true, baseSeeder)

// pId := createProject(e)
// _, _, sId := createScene(e, pId)

// // Add NLSLayer
// _, _, layerId := addNLSLayerSimple(e, sId)

// // Update NLSLayer
// _, _ = updateNLSLayer(e, layerId)

// // Remove NLSLayer
// _, _ = removeNLSLayer(e, layerId)
// }
4 changes: 0 additions & 4 deletions server/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/ravilushqa/otelgqlgen v0.8.0 h1:x48k+D1GMgm87xhMO2Lekrr9YGzFbpG3yijn9GpxuAY=
github.com/ravilushqa/otelgqlgen v0.8.0/go.mod h1:6JO5YO2iY4POC7R6yB/L/RKXCcyISL8qQt5NnHOhh0o=
github.com/reearth/reearthx v0.0.0-20230728095451-b9d255b762d5 h1:FUjyN05gB3OeF+CyhUZ5LDrx8TLmjI+b8DueZMtKq2A=
github.com/reearth/reearthx v0.0.0-20230728095451-b9d255b762d5/go.mod h1:O4zFr6ks8jDKfgy9NBpZKp31jpmAPnfOtMQK9B6xX54=
github.com/reearth/reearthx v0.0.0-20230825065409-20e5d57ed3cf h1:84IW4YBa6xjxJml/F/jh51WR6WGlcI6QsRVACi5PhwQ=
github.com/reearth/reearthx v0.0.0-20230825065409-20e5d57ed3cf/go.mod h1:O4zFr6ks8jDKfgy9NBpZKp31jpmAPnfOtMQK9B6xX54=
github.com/reearth/reearthx v0.0.0-20230825072907-543ac159f33b h1:7IsqB7KdGzp0hwlOIGb2imQW8mWJ9Ua9Ad5pAGNYaRs=
github.com/reearth/reearthx v0.0.0-20230825072907-543ac159f33b/go.mod h1:b8EygPZ9VcMv9vTbnl/oz3PU/wHz3wpBa4rc7W7URjw=
github.com/robertkrimen/godocdown v0.0.0-20130622164427-0bfa04905481/go.mod h1:C9WhFzY47SzYBIvzFqSvHIR6ROgDo4TtdTuRaOMjF/s=
Expand Down
1 change: 0 additions & 1 deletion server/gql/layer.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -298,5 +298,4 @@ extend type Mutation {
importLayer(input: ImportLayerInput!): ImportLayerPayload
attachTagToLayer(input: AttachTagToLayerInput!): AttachTagToLayerPayload
detachTagFromLayer(input: DetachTagFromLayerInput!): DetachTagFromLayerPayload

}
81 changes: 81 additions & 0 deletions server/gql/newlayer.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# TODO: Make LayerGroup Real
interface NLSLayer {
id: ID!
layerType: String!
sceneId: ID!
title: String!
visible: Boolean!
infobox: Infobox
tags: [LayerTag!]!
}

type NLSLayerSimple implements NLSLayer {
id: ID!
layerType: String!
sceneId: ID!
config: JSON
title: String!
visible: Boolean!
infobox: Infobox
tags: [LayerTag!]!
scene: Scene
}

type NLSLayerGroup implements NLSLayer {
id: ID!
layerType: String!
sceneId: ID!
children: [NLSLayer]!
childrenIds: [ID!]!
config: JSON
title: String!
visible: Boolean!
infobox: Infobox
tags: [LayerTag!]!
scene: Scene
}

# InputType

input AddNLSLayerSimpleInput {
parentLayerId: ID!
layerType: String!
sceneID: ID!
config: JSON
index: Int
}

input RemoveNLSLayerInput {
layerId: ID!
}

input UpdateNLSLayerInput {
layerId: ID!
name: String
visible: Boolean
}

# Payload

type AddNLSLayerSimplePayload {
layers: NLSLayerSimple!
}

type RemoveNLSLayerPayload {
layerId: ID!
}

type UpdateNLSLayerPayload {
layer: NLSLayer!
}

# TODO
# extend type Query{
# newLayer(id: ID!): NLSLayer
# }

extend type Mutation {
addNLSLayerSimple(input: AddNLSLayerSimpleInput!): AddNLSLayerSimplePayload
removeNLSLayer(input: RemoveNLSLayerInput!): RemoveNLSLayerPayload
updateNLSLayer(input: UpdateNLSLayerInput!): UpdateNLSLayerPayload
}
1 change: 1 addition & 0 deletions server/gql/scene.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type Scene implements Node {
team: Team
property: Property
rootLayer: LayerGroup
newLayers: [NLSLayer!]!
stories: [Story!]!
styles: [Style!]!
datasetSchemas(first: Int, last: Int, after: Cursor, before: Cursor): DatasetSchemaConnection!
Expand Down
10 changes: 10 additions & 0 deletions server/gqlgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ models:
resolver: true
rootLayer:
resolver: true
newLayers:
resolver: true
datasetSchemas:
resolver: true
tags:
Expand Down Expand Up @@ -390,3 +392,11 @@ models:
resolver: true
pluginExtension:
resolver: true
NLSLayerSimple:
fields:
scene:
resolver: true
NLSLayerGroup:
fields:
scene:
resolver: true
Loading

0 comments on commit c832483

Please sign in to comment.