Skip to content

Commit

Permalink
APIGOV-26588 graphQL parser (#725)
Browse files Browse the repository at this point in the history
* APIGOV-26588 add graphQL api type

* APIGOV-26588 graphql parser
  • Loading branch information
alrosca authored Jan 25, 2024
1 parent 810c65e commit 29a36a6
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/apic/definitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const (
Unstructured = "unstructured"
Specification = "specification"
Swagger = "swagger"
GraphQL = "graphql"
GraphQL = "graphql-sdl"

SubscriptionSchemaNameSuffix = ".authsubscription"
DefaultSubscriptionWebhookName = "subscriptionwebhook"
Expand Down
29 changes: 29 additions & 0 deletions pkg/apic/specgraphql.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package apic

type graphQLProcessor struct {
spec []byte
}

func newGraphQLSpecProcessor(resourceSpec []byte) SpecProcessor {
return &graphQLProcessor{spec: resourceSpec}
}

func (p *graphQLProcessor) GetResourceType() string {
return GraphQL
}

func (p *graphQLProcessor) GetVersion() string {
return ""
}

func (p *graphQLProcessor) GetDescription() string {
return ""
}

func (p *graphQLProcessor) GetEndpoints() ([]EndpointDefinition, error) {
return []EndpointDefinition{}, nil
}

func (p *graphQLProcessor) GetSpecBytes() []byte {
return p.spec
}
6 changes: 6 additions & 0 deletions pkg/apic/specparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ func (s *SpecResourceParser) createProcessorWithResourceType() error {
s.specProcessor, err = s.parseProtobufSpec()
case AsyncAPI:
s.specProcessor, err = s.parseAsyncAPISpec()
case GraphQL:
s.specProcessor, err = s.parseGraphQLSpec()
}
return err
}
Expand Down Expand Up @@ -157,6 +159,10 @@ func (s *SpecResourceParser) parseWSDLSpec() (SpecProcessor, error) {
return newWsdlProcessor(def, s.resourceSpec), nil
}

func (s *SpecResourceParser) parseGraphQLSpec() (SpecProcessor, error) {
return newGraphQLSpecProcessor(s.resourceSpec), nil
}

func (s *SpecResourceParser) parseOAS2Spec() (SpecProcessor, error) {
swaggerObj := &oas2Swagger{}
// lowercase the byte array to ensure keys we care about are parsed
Expand Down

0 comments on commit 29a36a6

Please sign in to comment.