Closed
Description
I'm trying to create a DSL query but I got the following error on the query compilation:
GraphQLError: Invalid field for <DSLQuery>: <DSLField QueryGTEMMetadata::clipsMetadata>
The instance init:
class MyClient():
SCHEMA_FILE_NAME = "gtem_schema.graphql"
@classmethod
def _get_my_gql_scheme(cls) -> str:
location = f"{os.path.dirname(os.path.abspath(__file__))}/gql/{cls.SCHEMA_FILE_NAME}"
schema_str = open(location).read()
return schema_str
def __init__(self, env: str = "production") -> None:
super().__init__(env)
self.s3fs = boto3.client('s3')
transport = RequestsHTTPTransport(url=f'{self.config["graphql_api"]["host"]}', verify=True, retries=3)
self.gql_client = Client(schema=self._get_my_gql_scheme(), transport=transport)
**self.gql_dsl_schema = DSLSchema(self.gql_client.schema)**
The DSLQuery compilation issue
main_query = self.gql_dsl_schema.QueryGTEMMetadata.clipsMetadata
select_query = main_query .select(self.gql_dsl_schema.GTEMMetadataWithArtifactsGQL.gtemVersion)
query = dsl_gql(DSLQuery(select_query)) # <- it's failed herer
result = self.gql_client.execute(query)
The gtem_schema.graphql content
schema {
query: QueryGTEMMetadata
}
type QueryGTEMMetadata {
"""Gets gtem metadata by clip list"""
clipsMetadata(clipList: [String!]!, version: String = null): [GTEMMetadataWithArtifactsGQL!]!
}
type GTEMMetadataWithArtifactsGQL {
usedCameras: [String!]!
coordinateCamera: String!
cameraConfHash: String!
sessionName: String!
gtemVersion: String!
packageVersion: String!
dataPath: String!
artifacts: [GTEMArtifactGQL!]
}
type GTEMArtifactGQL {
filePath: String!
clipNames: [String!]!
startFrameId: Int!
endFrameId: Int!
startGrabIndex: Int!
endGrabIndex: Int!
id: String
startUtcMicro: Int
endUtcMicro: Int
}
Full logs and traceback:
DEBUG:gql.dsl:Creating <DSLType <GraphQLObjectType 'QueryGTEMMetadata'>>)
DEBUG:gql.dsl:Creating <DSLField QueryGTEMMeta[data::clipsMetadata>]()
DEBUG:gql.dsl:Added arguments {'clipList': ['name5'], 'version': None} in field <DSLField QueryGTEMMeta[data::clipsMetadata>]())
DEBUG:gql.dsl:Creating <DSLType <GraphQLObjectType 'GTEMMetadataWithArtifactsGQL'>>)
DEBUG:gql.dsl:Creating <DSLField GTEMMetadataWithArtifactsGQL::gtemVersion>
DEBUG:gql.dsl:Added fields: (<DSLField GTEMMetadataWithArtifactsGQL::gtemVersion>,) in <DSLField QueryGTEMMeta[data::clipsMetadata>]()
---------------------------------------------------------------------------
GraphQLError Traceback (most recent call last)
/workspace/client/doogle/gtem.py in _get_metadata_list(self, returned_fields, clip_names, version)
111 clips_query = self.gql_dsl_schema.QueryGTEMMetadata.clipsMetadata
112 select_query = clips_query.select(self.gql_dsl_schema.GTEMMetadataWithArtifactsGQL.gtemVersion)
--> 113 query = dsl_gql(DSLQuery(select_query))
114 # self.gql_dsl_schema.GTEMMetadataWithArtifactsGQL.artifacts.select(self.gql_dsl_schema.GTEMArtifactGQL.clipNames)
115 result = self.gql_client.execute(query)
/opt/conda/envs/doogle_client/lib/python3.7/site-packages/gql/dsl.py in __init__(self, *fields, **fields_with_alias)
412 self.variable_definitions = DSLVariableDefinitions()
413
--> 414 DSLSelector.__init__(self, *fields, **fields_with_alias)
415
416
/opt/conda/envs/doogle_client/lib/python3.7/site-packages/gql/dsl.py in __init__(self, *fields, **fields_with_alias)
318
319 if fields or fields_with_alias:
--> 320 self.select(*fields, **fields_with_alias)
321
322 @abstractmethod
/opt/conda/envs/doogle_client/lib/python3.7/site-packages/gql/dsl.py in select(self, *fields, **fields_with_alias)
353
354 if not self.is_valid_field(field):
--> 355 raise GraphQLError(f"Invalid field for {self!r}: {field!r}")
356
357 # Get a list of AST Nodes for each added field
GraphQLError: Invalid field for <DSLQuery>: <DSLField QueryGTEMMetadata::clipsMetadata>
System info (please complete the following information):
- OS: Linux
- Python version: Python 3.7.12
- gql version: Version: 3.1.0
- graphql-core version: Version: 3.2.0