MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / Craft

Method Craft

pkg/attestation/crafter/materials/graphql.go:50–73  ·  view source on GitHub ↗
(ctx context.Context, filepath string)

Source from the content-addressed store, hash-verified

48}
49
50func (i *GraphQLCrafter) Craft(ctx context.Context, filepath string) (*api.Attestation_Material, error) {
51 i.logger.Debug().Str("path", filepath).Msg("decoding GraphQL SDL file")
52
53 content, err := os.ReadFile(filepath)
54 if err != nil {
55 return nil, fmt.Errorf("can't open the file: %w", err)
56 }
57
58 source := &ast.Source{Name: filepath, Input: string(content)}
59 doc, parseErr := parser.ParseSchema(source)
60 if parseErr != nil {
61 i.logger.Debug().Err(parseErr).Msg("error decoding file")
62 return nil, fmt.Errorf("invalid GraphQL SDL file: %w", ErrInvalidMaterialType)
63 }
64
65 m, err := uploadAndCraft(ctx, i.input, i.backend, filepath, i.logger)
66 if err != nil {
67 return nil, err
68 }
69
70 i.injectAnnotations(m, doc)
71
72 return m, nil
73}
74
75func (i *GraphQLCrafter) injectAnnotations(m *api.Attestation_Material, doc *ast.SchemaDocument) {
76 if m.Annotations == nil {

Callers 1

TestGraphQLCraftFunction · 0.95

Calls 3

injectAnnotationsMethod · 0.95
uploadAndCraftFunction · 0.85
DebugMethod · 0.45

Tested by 1

TestGraphQLCraftFunction · 0.76