avanov / graphql-dsl

Compose GraphQL queries by composing Python types!
https://graphql-dsl.rtfd.io/
MIT License
5 stars 2 forks source link

[cli]: object has no attribute 'operation_types' #8

Open iwconfig opened 1 year ago

iwconfig commented 1 year ago

The following error occur when using the CLI to generate definitions.

In [54]: from graphql_dsl.parser import parse

In [55]: parse(Path('sdl.gql').read_text())
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In [55], line 1
----> 1 parse(Path('sdl.gql').read_text())

File /opt/venv/lib/python3.10/site-packages/graphql_dsl/parser/__init__.py:6, in parse(src)
      4 def parse(src: str) -> graphql.DocumentNode:
      5     schema = graphql.parse(src)
----> 6     schema.definitions[0].operation_types[0].type.name.value
      7     return schema

AttributeError: 'InputObjectTypeDefinitionNode' object has no attribute 'operation_types'

another example using the sdl of https://countries.trevorblades.com/graphql

In [56]: parse(Path('sdl-trevorblades.gql').read_text())
...
AttributeError: 'DirectiveDefinitionNode' object has no attribute 'operation_types'

Python version 3.10