lib/graphql-docs/helpers.rb in graphql-docs-1.6.1 vs lib/graphql-docs/helpers.rb in graphql-docs-1.7.0
- old
+ new
@@ -60,20 +60,24 @@
def graphql_scalar_types
@parsed_schema[:scalar_types] || []
end
- def split_into_metadata_and_contents(contents)
+ def split_into_metadata_and_contents(contents, parse: true)
opts = {}
pieces = yaml_split(contents)
if pieces.size < 4
raise RuntimeError.new(
"The file '#{content_filename}' appears to start with a metadata section (three or five dashes at the top) but it does not seem to be in the correct format.",
)
end
# Parse
begin
- meta = YAML.load(pieces[2]) || {}
+ if parse
+ meta = YAML.load(pieces[2]) || {}
+ else
+ meta = pieces[2]
+ end
rescue Exception => e # rubocop:disable Lint/RescueException
raise "Could not parse YAML for #{name}: #{e.message}"
end
[meta, pieces[4]]
end