Skip to content

How to create a type dynamically #1124

Open
@happy-machine

Description

@happy-machine

Hi there, thanks for this awesome library.

Ive got two related questions its probably less messy to put in one issue, i hope thats ok.

I want to map types to external objects (either from a json or an external python binding sourced object)

In the docs i've found:
https://graphql-rust.github.io/types/objects/complex_fields.html
https://docs.rs/juniper/latest/juniper/trait.GraphQLType.html

I'm trying to follow complex fields but can't get the import to work.
Example sais:
#[macro_use] extern crate juniper;

But this won't compile for me, i have #[macro_use] in my lib.js (im making a library) but i get an error trying to use graphql_object (which im doing exactly as in the example) which is: can't find macro graphql_object in this scope.

Is this the way to define custom types? ie. if i have a hash map i want to map over and translate the keys to fields and the values to types? (do you have any examples of this anywhere). I'm quite new to rust and the combination of graphql and rust syntax is quite intense!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions