Code Monkey home page Code Monkey logo

frappe_graphql's People

Contributors

abadulrehman avatar afalfallaj avatar assemmarwan avatar e-lobo avatar fahimalizain avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

frappe_graphql's Issues

Single Doctype should not require any query to be passed

For querying a doctype, name field is required to be passed, which is fine. However, it should not apply to single doctypes for example, System Settings is a single doctype but in order to query System Settings I'd have to do;

query SystemSettings {
  SystemSettings(name: "System Settings") {
    name
  }
}

Generating GraphQL enums on a Frappe Select Field

I believe it should possible to generate GraphQL types on a field like select, but do mention your thoughts on this.

Here for example, I rely on address type, which only has these values as option. So, Ideally we can generate type for this like so; AddressType.Billing etc..

image image

unable to use frappe_graphql on ERPNext 14

Hi,
we are trying to use the documentation given in README.md to try to setup graphql on a fresh installation of ERPNext.

steps followed

ran docker instance from pwd.yml , then on frontend site (comes as default with pwd.yml)

(env) frappe@9c5a19b4ca7e:~/frappe-bench$ bench get --resolve-deps https://github.com/leam-tech/frappe_graphql

Following apps will be installed
1. https://github.com/leam-tech/frappe_graphql 
Getting frappe_graphql
$ git clone https://github.com/leam-tech/frappe_graphql   --origin upstream
Cloning into 'frappe_graphql'...
remote: Enumerating objects: 1207, done.
remote: Counting objects: 100% (53/53), done.
remote: Compressing objects: 100% (47/47), done.
remote: Total 1207 (delta 23), reused 17 (delta 6), pack-reused 1154
Receiving objects: 100% (1207/1207), 257.63 KiB | 641.00 KiB/s, done.
Resolving deltas: 100% (801/801), done.
Installing frappe_graphql
$ /home/frappe/frappe-bench/env/bin/python -m pip install --quiet --upgrade -e /home/frappe/frappe-bench/apps/frappe_graphql 
$ bench build --app frappe_graphql
โœ” Application Assets Linked                                                                                                                                                                                 


yarn run v1.22.19
$ node esbuild --production --apps frappe_graphql --run-build-command
File                                                        Size

 DONE  Total Build Time: 613.523ms

clean: postcss.plugin was deprecated. Migration guide:
https://evilmartians.com/chronicles/postcss-8-plugin-migration
clean: postcss.plugin was deprecated. Migration guide:
https://evilmartians.com/chronicles/postcss-8-plugin-migration
Done in 1.75s.
WARN: restart failed: Couldn't find supervisorctl in PATH

and when trying to generate sdl this happens
(env) frappe@9c5a19b4ca7e:~/frappe-bench/sites$ bench --site frontend graphql generate_sdl

Generating in Directory: /home/frappe/frappe-bench/sites/frontend/doctype_sdls
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 109, in <module>
    main()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name="bench")
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 29, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe_graphql/frappe_graphql/commands/__init__.py", line 43, in generate_sdl
    make_doctype_sdl_files(
  File "/home/frappe/frappe-bench/apps/frappe_graphql/frappe_graphql/utils/generate_sdl/__init__.py", line 109, in make_doctype_sdl_files
    sdl = get_doctype_sdl(doctype=doctype, options=options)
  File "/home/frappe/frappe-bench/apps/frappe_graphql/frappe_graphql/utils/generate_sdl/doctype.py", line 20, in get_doctype_sdl
    sdl, defined_fieldnames = get_basic_doctype_sdl(meta, options=options, generated_enums=generated_enums)
  File "/home/frappe/frappe-bench/apps/frappe_graphql/frappe_graphql/utils/generate_sdl/doctype.py", line 70, in get_basic_doctype_sdl
    sdl += f"\n  {get_field_sdl(meta, field, options=options, generated_enums=generated_enums)}"
  File "/home/frappe/frappe-bench/apps/frappe_graphql/frappe_graphql/utils/generate_sdl/doctype.py", line 187, in get_field_sdl
    return f"{docfield.fieldname}: {get_graphql_type(meta, docfield, options=options, generated_enums=generated_enums)}"
  File "/home/frappe/frappe-bench/apps/frappe_graphql/frappe_graphql/utils/generate_sdl/doctype.py", line 239, in get_graphql_type
    frappe.throw(f"Invalid fieldtype: {docfield.fieldtype}")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 525, in throw
    msgprint(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 493, in msgprint
    _raise_exception()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 442, in _raise_exception
    raise raise_exception(msg)
frappe.exceptions.ValidationError: Invalid fieldtype: Icon

Generate the sdls throw's AttributeError: 'NoneType' object has no attribute 'values'

Once I Generate the sdls. I get AttributeError: 'NoneType' object has no attribute 'values' error.

if name in generated_enums.values():

seems generated_enums in line 262 reach empty.

I have added hasattr before and I don't get this error anymore. I don't why I get this error but I am using frappe & erpnext v13.5.2

if hasattr(generated_enums,'values'):
        if name in generated_enums.values():
            name = remove_reserved_characters(
                f"{doctype}{(docfield.fieldname).title()}SelectOptions"
                .replace(" ", ""))

Improve error message "Please fix your HEAD on select field"

First, this is a dream come true. Thank you very much for this work! Is this package considered production ready?

When creating the sdl I receive the following exception:
frappe.exceptions.ValidationError: Please fix your HEAD on select field: 96880af9cf

I guess I understand the problem after reading the code. However it would help if the description was better. Also, I have no idea how to find this field to fix it. Is there any way to search for this hash?

Fetching fields of connected docs is slow

Running the following query takes around 3 seconds:

SalesOrders(first: 10) {
  totalCount
  edges {
    node {
      name
      address_name {
        name
        address_title
        address_line1
        address_line2
        pincode
        city
      }
    }
  }
}

What's especially interesting is, that fetching many subfields (in this case 6 from address_name) is much slower than just fetching a few - so it seems, that the db is queried individually for each subfield, which probably is what makes it so much slower.

Just querying a single subfield of address_name takes around 1 - 1.2 seconds. It's still slow, but bearable.

Not querying subfields at all is around 300 ms. So >700 ms for 10 additional docs is still a lot but I don't know if that can be sped up easily by fetching multiple docs at once. But in this case it would still be faster to send 10 parallel REST queries to the server, which get answered in around 150 ms simultaneously.

Cannot filter lists using child doctype

Frappe allows getting a list of Doctype with filters applied on Child Doctype.
For example, address here could be filtered using Dynamic Link
image

Ideally I believe, DBFilterInput could allow input of doctype option that is non-mandatory. Which would be manipulated purposefully for filter usage..

input DBFilterInput {
  doctype: String
  fieldname: String!
  operator: DBFilterOperator
  value: String!
}

Queries return translated values

Running a query returns translated values (e.g. German "Entwurf" instead of "Draft" for a "status" field in ERPNext).

For an API, the untranslated values should be returned.

Querying a doc should allow filtering/sorting on Child Table

Given this ability, it would allow added bonus of requesting only what is desired. And this could be the same as current use of generating [DBFilterInput] for filters, as well as SortingInput for each field in the child table.

User(name: "[email protected]"){
    roles(filter: [
        {
            fieldname: "role"
            operator: LIKE
            value: "Manager"
        }
    ]){
        name
    }
}

In my use case I'd prefer only getting single row in the child table hence filtering by name.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.