Hello, I'm seeing an error related to GraphQL when...
# general
c
Hello, I'm seeing an error related to GraphQL when running
./pants test ::
. It seems to come from the ariadne package, and looks as follows.
Copy code
E   graphql.error.syntax_error.GraphQLSyntaxError: Syntax Error: Unexpected <EOF>
E
E   GraphQL request:238:1
E   237 |
E   238 |
E       | ^
E   239 |
I've pasted the stack trace in the thread to avoid myself from adding a super long message into the channel. I initially suspected this may be some issue related to ariadne not specifying their dependencies correctly. Previously, I've added to the
overrides
field of the
pipenv_requirements
target in the root
BUILD
file in order to resolve those types of issues, e.g.
Copy code
pipenv_requirements(
    ...
    overrides = {
        "google-cloud-pubsub": { "dependencies": [":requirements#setuptools"] },
    }
)
However, the error message is not easy for me to understand in this case, and I can't quite tell what kind of error this is, and whether it is due to the same root cause. I'm wondering if the Pants engineering team has any tips on how I can diagnose what is going wrong here and how I could go about trying to resolve this. I've already run the following, and see that ariadne is at the very least correctly listed as a dependency of my target.
Copy code
➜  ./pants dependencies front_porch/modules/graphql_views/executable_schema.py
//:requirements#ariadne
...
Stacktrace
Copy code
_ ERROR collecting tests/functional/interaction_history/test_interaction_history_utils.py _

< REDACTED FOR BREVITY >

front_porch/modules/graphql_views/executable_schema.py:386: in <module>
    executable_schema = make_executable_schema(_schema_pieces, _resolvers, upload_scalar)
/Users/hughhan/.cache/pants/named_caches/pex_root/venvs/d705eb07a9504cff30c9db408d69d319464c0389/7a2690d4c50569a1b21d9e60e967c4e24aa15de2/lib/python3.9/site-packages/ariadne/executable_schema.py:26: in make_executable_schema
    ast_document = parse(type_defs)
/Users/hughhan/.cache/pants/named_caches/pex_root/venvs/d705eb07a9504cff30c9db408d69d319464c0389/7a2690d4c50569a1b21d9e60e967c4e24aa15de2/lib/python3.9/site-packages/graphql/language/parser.py:100: in parse
    return parser.parse_document()
/Users/hughhan/.cache/pants/named_caches/pex_root/venvs/d705eb07a9504cff30c9db408d69d319464c0389/7a2690d4c50569a1b21d9e60e967c4e24aa15de2/lib/python3.9/site-packages/graphql/language/parser.py:180: in parse_document
    definitions=self.many(TokenKind.SOF, self.parse_definition, TokenKind.EOF),
/Users/hughhan/.cache/pants/named_caches/pex_root/venvs/d705eb07a9504cff30c9db408d69d319464c0389/7a2690d4c50569a1b21d9e60e967c4e24aa15de2/lib/python3.9/site-packages/graphql/language/parser.py:1074: in many
    nodes = [parse_fn()]
/Users/hughhan/.cache/pants/named_caches/pex_root/venvs/d705eb07a9504cff30c9db408d69d319464c0389/7a2690d4c50569a1b21d9e60e967c4e24aa15de2/lib/python3.9/site-packages/graphql/language/parser.py:218: in parse_definition
    raise self.unexpected()
E   graphql.error.syntax_error.GraphQLSyntaxError: Syntax Error: Unexpected <EOF>
E
E   GraphQL request:238:1
E   237 |
E   238 |
E       | ^
E   239 |
c
It looks like an issue with the contents of a gql string in
tests/functional/interaction_history/test_interaction_history_utils.py
?
The traceback is in a GraphQL parser, trying to parse a GraphQL document… so most likely a typo in that area, I’d guess.
c
When I run the test via
pytest
, it works fine. But running via
./pants test ::
causes this exception to be raised...
😲 1
Okay, I think I figured it out. This is because I was using
ariadne.load_schema_from_path
, which reads
*.graphql
files from directories, which would fail if they aren't added as explicit dependences 😞
c
Makes sense, yes.