How to use the gql.config.Config function in gql

To help you get started, we’ve selected a few gql examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github graphql-python / gql-next / tests / _codec / test_transform.py View on Github external
def mock_codec_config(swapi_schema, swapi_parser, mocker):
    renderer = DataclassesRenderer(swapi_schema, Config(schema='schemaurl', endpoint='schemaurl', documents=''), internal_ns=True)

    mocker.patch.object(transform, 'get_schema', return_value=swapi_schema)
    mocker.patch.object(transform, 'get_parser', return_value=swapi_parser)
    mocker.patch.object(transform, 'get_renderer', return_value=renderer)
github graphql-python / gql-next / tests / test_renderer_dataclasses.py View on Github external
def swapi_dataclass_renderer(swapi_schema):
    return DataclassesRenderer(swapi_schema, Config(schema='schemaurl', endpoint='schemaurl', documents=''))
github graphql-python / gql-next / tests / test_renderer_dataclasses.py View on Github external
}
    )

    schema = GraphQLSchema(query_type, types=[length_unit_enum, starship_type])

    query = """
        query GetStarship {
            ship(id: "Enterprise") {
                id
                name
                length(unit: METER)
            }
        }
    """
    query_parser = QueryParser(schema)
    query_renderer = DataclassesRenderer(schema, Config(schema='schemaurl', endpoint='schemaurl', documents=''))
    parsed = query_parser.parse(query)
    rendered = query_renderer.render(parsed)

    m = module_compiler(rendered)
    response = m.GetStarship.from_json("""
        {
            "data": {
                "ship": {
                    "id": "Enterprise",
                    "name": "Enterprise",
                    "length": 100
                }
            }
        }
    """)
github graphql-python / gql-next / tests / test_renderer_dataclasses.py View on Github external
'people': GraphQLField(
                    GraphQLList(GraphQLNonNull(PersonType)),
                    resolve=lambda obj, info: {'name':'eran'}
                )
            }))

    query = """
            query GetPeople {
              people {
                name
              }
            }
        """

    parser = QueryParser(schema)
    dataclass_renderer = DataclassesRenderer(schema, Config(schema='schemaurl', endpoint='schemaurl', documents=''))

    parsed = parser.parse(query)
    rendered = dataclass_renderer.render(parsed)

    m = module_compiler(rendered)

    now = datetime.now()

    call_mock = mocker.patch.object(m.Client, 'call')
    call_mock.return_value = """
       {
           "data": {
               "people": [
                  {
                    "name": "eran"
                  },
github graphql-python / gql-next / tests / test_renderer_dataclasses.py View on Github external
def github_dataclass_renderer(swapi_schema):
    return DataclassesRenderer(swapi_schema, Config(schema='schemaurl', endpoint='schemaurl', documents=''))
github graphql-python / gql-next / gql / cli.py View on Github external
def init(schema, endpoint, root, config_filename):
    if isfile(config_filename):
        click.confirm(f'{config_filename} already exists. Are you sure you want to continue?', abort=True)

    if endpoint == 'same as schema':
        endpoint = schema

    config = Config(
        schema=schema,
        endpoint=endpoint,
        documents=join_paths(root, '**/*.graphql')
    )

    config.save(config_filename)

    click.echo(f"Config file generated at {click.style(config_filename, fg='bright_white')}\n\n")