I would like to read my fields available from a specific Type.
__type(name: "datasheet_2") {
fields {
name
}
}
See image below, it will generate a null result the first time building, but the second time its there!
Suggesting the schema is generated afterwards..

Is it possible to hook after the update schema step and have the result passed to context of pages?
This would solve my case that seems not possible with the graphql specification see https://github.com/gatsbyjs/gatsby/issues/5635
Interesting by quering the root type i get a result by the first build:
__type(name: "SpecificationsYaml") {
fields {
name
}
}
so i get title, entryDate, isPromoted, datasheet.. etc.
my data structure is as follows:
title: New Machine T800
entryDate: 21.05.18
isPromoted: true
mediaimages:
- image: /media/imgkallfass_aus2.jpg
- image: /media/imgmccain1500_2_small.jpg
datasheet:
data_available: July 2018
data_impressions: 22 Mio.
data_location: Switzerland
data_units: '6'
data_year: '2013'
description: |-
fsfsfsdf saf.
sdfas
Basically I want to query the fields under Datasheet..
I am using gatsby-transformer-yaml.
So problem here is that we generate schema twice and we do add suffixes to autogenerated type names that were already defined before. So in createPages (after first schema generateion and before second one) your Datasheet type will most likely be just datasheet (without _2 suffix).
You can also first do introspection query to get type name of datasheet field:
__type(name:"SpecificationsYaml") {
fields {
name
type {
name
}
}
}
retrieve type.name for datasheet field and use it and second introspection query.
Ultimate solution in gatsby core to keep types consistent between schema generation runs would be to reset seenNames here https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/src/schema/create-type-name.js when we start to generate schema ( https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/src/schema/build-node-types.js#L32 ), but I imagine it would break a lot of pages that use suffixed names in their fragments in page/layout queries. Maybe this is something we can do in v2
indeed it worked without suffix..
Most helpful comment
So problem here is that we generate schema twice and we do add suffixes to autogenerated type names that were already defined before. So in
createPages(after first schema generateion and before second one) yourDatasheettype will most likely be justdatasheet(without_2suffix).You can also first do introspection query to get type name of
datasheetfield:retrieve
type.namefordatasheetfield and use it and second introspection query.Ultimate solution in gatsby core to keep types consistent between schema generation runs would be to reset
seenNameshere https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/src/schema/create-type-name.js when we start to generate schema ( https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/src/schema/build-node-types.js#L32 ), but I imagine it would break a lot of pages that use suffixed names in their fragments in page/layout queries. Maybe this is something we can do in v2