Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] GraphQL types not being generated #76

Open
jakevollkommer opened this issue Jun 15, 2024 · 4 comments
Open

[BUG] GraphQL types not being generated #76

jakevollkommer opened this issue Jun 15, 2024 · 4 comments

Comments

@jakevollkommer
Copy link

Using a minimum configration, I can't get the type to generate pydantic classes in the output file.

graphql.config.yml

projects:
  default:
    schema: ./schema.graphql
    extensions:
      turms:
        out_dir: api
        stylers:
          - type: turms.stylers.capitalize.CapitalizeStyler
          - type: turms.stylers.snake_case.SnakeCaseStyler
        plugins:
          - type: turms.plugins.enums.EnumsPlugin
          - type: turms.plugins.inputs.InputsPlugin
        processors:
          - type: turms.processors.black.BlackProcessor
          - type: turms.processors.isort.IsortProcessor
        scalar_definitions:
          ID: str

schema.graphql

type TestType {
  id: ID
  name: String
}

input TestInput {
  name: String
}

api/schema.py

from enum import Enum
from typing import Optional

from pydantic import BaseModel


class TestInput(BaseModel):
    name: Optional[str]

As you can see, I get enums and inputs, but no types.

More info:

    Hardware Overview:

      Model Name: MacBook Pro
      Model Identifier: MacBookPro18,2
      Model Number: Z14X000EUX/A
      Chip: Apple M1 Max
      Total Number of Cores: 10 (8 performance and 2 efficiency)
      Memory: 64 GB
      System Firmware Version: 10151.101.3
      OS Loader Version: 10151.101.3
      Serial Number (system): H62X42Y6FC
      Hardware UUID: 479FB683-C073-5D5F-BE74-F93305B60B53
      Provisioning UDID: 00006001-000240691144801E
      Activation Lock Status: Enabled

Python 3.12.3
turms 0.5.0
pydantic 1.10.16
pydantic_core 2.18.2
graphql-core 3.2.3
black 24.4.2
isort 5.13.2

@jakevollkommer
Copy link
Author

@jhnnsrs I figured it would be default for the type to be generated, am I missing something?

@jhnnsrs
Copy link
Owner

jhnnsrs commented Jun 16, 2024

@jakevollkommer hi there! Thanks for submitting the issue!

Generally there is an 'Objects plugin' that generates the types from the schema that you could add and that would generate models from that. M

However the main idea if you want to use turms on the client side is to go through the 'documents' driven API Generation (utilizing the fragments, operations and funcs) plugins.

Not sure if this is what you are looking for though? What would you like to achieve with the objects?

However for most usecases I would recommend checking

@jakevollkommer
Copy link
Author

Thanks for the response! I actually managed to figure out to use the plugin. I had to dig through the source to eventually figure it out.

Our use case is essentially type sharing between the typescript and python parts of our backend, specifically where the python bits contain LLM operations that use pydantic classes to define LLM tools

I will check out the documents idiom as well!

@jhnnsrs
Copy link
Owner

jhnnsrs commented Sep 20, 2024

Hey sorry for the long wait for the reply! Would you care for explaining where you got stuck? I am planning to "update" / "finally freaking write" the documentation in the next couple of weeks and would love some feedback, as well as your use case! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants