Git Product home page Git Product logo

gql-next's Introduction

DEPRECATION NOTICE: this package is deprecated in favor of the new changes made in gql over at https://github.com/graphql-python/gql

GQL: Python GraphQL Client Library

Build Status Coverage Status

Introduction

GQL is a GraphQL Client Python library intended to help Python application make GraphQL API call while enjoying the advantages that come with GraphQL.

  • Strongly Typed response objects (dynamically created in build time to match your query)
  • Query Validation that checks your code's queries against the GraphQL server's schema.

Installation

Simply install from PyPi:

pip install gql-next

Then go to your project folder and run gql init

Quick Start

gql works by parsing query files (**/*.graphql by default) into their own Python module where an class, named after the operation defined in the file, allows you to make that query and get a typed response.

For example, given the following file get_film.graphql file:

query GetFilm($id: ID!) {
  film(id: $id) {
    title
    director
  }
}

A get_film.py will be created defining a GetFilm class:

# AUTOGENERATED file. Do not Change!
from typing import Any, Callable, Mapping, List
from enum import Enum
from dataclasses import dataclass
from dataclasses_json import dataclass_json
from gql.clients import Client, AsyncIOClient


@dataclass_json
@dataclass
class GetFilm:
    @dataclass_json
    @dataclass
    class GetFilmData:
        @dataclass_json
        @dataclass
        class Film:
            title: str
            director: str
        film: Film = None

    data: GetFilmData = None
    errors: Any = None

    @classmethod
    def execute(cls, id: str, on_before_callback: Callable[[Mapping[str, str], Mapping[str, str]], None] = None) -> GetFilm:
        ...

    @classmethod
    async def execute_async(cls, id: str, on_before_callback: Callable[[Mapping[str, str], Mapping[str, str]], None] = None) -> GetFilm:
        ...

Allowing you to make the GraphQL query:

from .get_film import GetFilm

result = GetFilm.execute('meaning_of_life')
film = result.data.film

Important notes:

  • Operations defined in graphql query must be named so that we can name the relevant Python Class which you can then import in your code

How it works

The gql client

gql init

Initializes a project to use GQL as client - writes a .gql.json configuration file.

gql run

Run through your project's files and compile GraphQL queries into into Python types.

gql watch

Useful during development. Listen to file changes in your project's folder and continuously builds GraphQL queries as they change. This allows you to:

  • Immediately verify query changes you make are valid.
  • Enjoy your IDE's autocomplete features on GraphQL auto-generated objects while developing as watch will auto-update them as you change queries.

Sponsors

gql-next's People

Contributors

ekampf 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  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

gql-next's Issues

Support for Fragments Import pattern

A useful pattern when doing component-based design is to have each component specify a graphql Fragment it needs for its data, and the data loading interface imports this fragment somehow:

# File butterfly_painter.py
FRAGMENT= '''
fragment Foo on Butterfly {
    wingColor
}
'''

def paint_butterfly(butterfly: Butterfly):
    return f'<img src="/img/wings/{butterfly_color}.png">'
# File workstuff
import butterfly_painter

QUERY= '''
query find_my_things {
    butterflies(size: LARGE) {
        ... butterfly_painter.FRAGMENT
    }
}
''' + butterfly_painter

So that if paint_butterfly is changed, the piece of the query it needs can me modified in the same file, instead of somewhere else.

This pattern has some issues, but the use-case (localizing data required for a component to the component) is important and we should support some way to handle it.

Custom Headers

I can't get custom headers to work. I'm happy to document the correct pattern if someone can show a simple example of what the package is expecting.

load_introspection_from_server does not use custom headers

Hello I'm trying to test gql but running gql run returned


[...]

  File "/home/rdebroiz/.virtualenvs/test_gql/lib/python3.7/site-packages/gql/utils_schema.py", line 22, in load_schema
    introspection = load_introspection_from_file(uri) if os.path.isfile(uri) else load_introspection_from_server(uri)
  File "/home/rdebroiz/.virtualenvs/test_gql/lib/python3.7/site-packages/gql/utils_schema.py", line 13, in load_introspection_from_server
    raise Exception(f'Query failed to run by returning code of {request.status_code}. {query}')
Exception: Query failed to run by returning code of 401.

[...]

I suspect the cause is that the custom headers are not used to load the schema from the configured endpoint.

def load_introspection_from_server(url):
    query = get_introspection_query()
    request = requests.post(url, json={'query': query})
    if request.status_code == 200:
        return request.json()['data']

    raise Exception(f'Query failed to run by returning code of {request.status_code}. {query}')

Here is what my .gql.json look likes:

{
  "schema": "http://hasura:10004/v1alpha1/graphql",
  "endpoint": "http://hasura:10004/v1alpha1/graphql",
  "documents": "./**/*.graphql",
  "custom_header": {
    "x-hasura-admin-secret": "adminpw",
    "x-hasura-access-key": "userpw"
  }
}

Consider updating dataclasses-json package

Today I tried installing gql-next for a new project, and using pipenv install --dev gql-next produced the following incompatibility message (collapsed since it's long):

$ pipenv install --dev gql-next
Installing gql-next…
Adding gql-next to Pipfile's [dev-packages]…
✔ Installation Succeeded
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
✘ Locking Failed!
[pipenv.exceptions.ResolutionFailure]:       req_dir=requirements_dir
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/lib/python3.7/site-packages/pipenv/utils.py", line 726, in resolve_deps
[pipenv.exceptions.ResolutionFailure]:       req_dir=req_dir,
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/lib/python3.7/site-packages/pipenv/utils.py", line 480, in actually_resolve_deps
[pipenv.exceptions.ResolutionFailure]:       resolved_tree = resolver.resolve()
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/lib/python3.7/site-packages/pipenv/utils.py", line 395, in resolve
[pipenv.exceptions.ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]:       pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches marshmallow==3.0.0rc6,>=2.0.0
[pipenv.exceptions.ResolutionFailure]:       Tried: 0.1.0, 0.1.0, 0.2.0, 0.2.0, 0.2.1, 0.2.1, 0.3.0, 0.3.0, 0.3.1, 0.3.1, 0.4.0, 0.4.0, 0.4.1, 0.4.1, 0.5.0, 0.5.0, 0.5.1, 0.5.1, 0.5.2, 0.5.2, 0.5.3, 0.5.3, 0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.5, 2.20.0, 2.20.0, 2.20.1, 2.20.1, 2.20.2, 2.20.2, 2.20.3, 2.20.3, 2.20.4, 2.20.4, 2.20.5, 2.20.5, 3.0.0, 3.0.0, 3.0.1, 3.0.1, 3.0.2, 3.0.2, 3.0.3, 3.0.3, 3.0.4, 3.0.4, 3.0.5, 3.0.5, 3.1.0, 3.1.0, 3.1.1, 3.1.1, 3.2.0, 3.2.0
[pipenv.exceptions.ResolutionFailure]:       Skipped pre-versions: 1.0.0a0, 1.0.0a0, 2.0.0a1, 2.0.0a1, 2.0.0b1, 2.0.0b1, 2.0.0b2, 2.0.0b2, 2.0.0b3, 2.0.0b3, 2.0.0b4, 2.0.0b4, 2.0.0b5, 2.0.0b5, 2.0.0rc1, 2.0.0rc1, 2.0.0rc2, 2.0.0rc2, 3.0.0a1, 3.0.0a1, 3.0.0b1, 3.0.0b1, 3.0.0b2, 3.0.0b2, 3.0.0b3, 3.0.0b3, 3.0.0b4, 3.0.0b4, 3.0.0b5, 3.0.0b5, 3.0.0b6, 3.0.0b6, 3.0.0b7, 3.0.0b7, 3.0.0b8, 3.0.0b8, 3.0.0b9, 3.0.0b9, 3.0.0b10, 3.0.0b10, 3.0.0b11, 3.0.0b11, 3.0.0b12, 3.0.0b12, 3.0.0b13, 3.0.0b13, 3.0.0b14, 3.0.0b14, 3.0.0b15, 3.0.0b15, 3.0.0b16, 3.0.0b16, 3.0.0b17, 3.0.0b17, 3.0.0b18, 3.0.0b18, 3.0.0b19, 3.0.0b19, 3.0.0b20, 3.0.0b20, 3.0.0rc1, 3.0.0rc1, 3.0.0rc2, 3.0.0rc2, 3.0.0rc3, 3.0.0rc3, 3.0.0rc4, 3.0.0rc4, 3.0.0rc5, 3.0.0rc5, 3.0.0rc6, 3.0.0rc6, 3.0.0rc7, 3.0.0rc7, 3.0.0rc8, 3.0.0rc8, 3.0.0rc9, 3.0.0rc9
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
 Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: ERROR: Could not find a version that matches marshmallow==3.0.0rc6,>=2.0.0
Tried: 0.1.0, 0.1.0, 0.2.0, 0.2.0, 0.2.1, 0.2.1, 0.3.0, 0.3.0, 0.3.1, 0.3.1, 0.4.0, 0.4.0, 0.4.1, 0.4.1, 0.5.0, 0.5.0, 0.5.1, 0.5.1, 0.5.2, 0.5.2, 0.5.3, 0.5.3, 0.5.4, 0.5.4, 0.5.5, 0.5.5, 0.6.0, 0.6.0, 0.7.0, 0.7.0, 1.0.0, 1.0.0, 1.0.1, 1.0.1, 1.1.0, 1.1.0, 1.2.0, 1.2.0, 1.2.1, 1.2.1, 1.2.2, 1.2.2, 1.2.3, 1.2.3, 1.2.4, 1.2.4, 1.2.5, 1.2.5, 1.2.6, 1.2.6, 2.0.0, 2.0.0, 2.1.0, 2.1.0, 2.1.1, 2.1.1, 2.1.2, 2.1.2, 2.1.3, 2.1.3, 2.2.0, 2.2.0, 2.2.1, 2.2.1, 2.3.0, 2.3.0, 2.4.0, 2.4.0, 2.4.1, 2.4.1, 2.4.2, 2.4.2, 2.5.0, 2.5.0, 2.6.0, 2.6.0, 2.6.1, 2.6.1, 2.7.0, 2.7.0, 2.7.1, 2.7.2, 2.7.2, 2.7.3, 2.7.3, 2.8.0, 2.8.0, 2.9.0, 2.9.0, 2.9.1, 2.9.1, 2.10.0, 2.10.0, 2.10.1, 2.10.1, 2.10.2, 2.10.2, 2.10.3, 2.10.3, 2.10.4, 2.10.4, 2.10.5, 2.10.5, 2.11.0, 2.11.0, 2.11.1, 2.11.1, 2.12.0, 2.12.0, 2.12.1, 2.12.1, 2.12.2, 2.12.2, 2.13.0, 2.13.0, 2.13.1, 2.13.1, 2.13.2, 2.13.2, 2.13.3, 2.13.3, 2.13.4, 2.13.4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 3.0.0b17, 3.0.0b18, 3.0.0b18, 3.0.0b19, 3.0.0b19, 3.0.0b20, 3.0.0b20, 3.0.0rc1, 3.0.0rc1, 3.0.0rc2, 3.0.0rc2, 3.0.0rc3, 3.0.0rc3, 3.0.0rc4, 3.0.0rc4, 3.0.0rc5, 3.0.0rc5, 3.0.0rc6, 3.0.0rc6, 3.0.0rc7, 3.0.0rc7, 3.0.0rc8, 3.0.0rc8, 3.0.0rc9, 3.0.0rc9
There are incompatible versions in the resolved dependencies.
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/lib/python3.7/site-packages/pipenv/utils.py", line 726, in resolve_deps
[pipenv.exceptions.ResolutionFailure]:       req_dir=req_dir,
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/lib/python3.7/site-packages/pipenv/utils.py", line 480, in actually_resolve_deps
[pipenv.exceptions.ResolutionFailure]:       resolved_tree = resolver.resolve()
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/lib/python3.7/site-packages/pipenv/utils.py", line 395, in resolve
[pipenv.exceptions.ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]:       pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches marshmallow==3.0.0rc6,>=2.0.0
[pipenv.exceptions.ResolutionFailure]:       Tried: 0.1.0, 0.1.0, 0.2.0, 0.2.0, 0.2.1, 0.2.1, 0.3.0, 0.3.0, 0.3.1, 0.3.1, 0.4.0, 0.4.0, 0.4.1, 0.4.1, 0.5.0, 0.5.0, 0.5.1, 0.5.1, 0.5.2, 0.5.2, 0.5.3, 0.5.3, 0.5.4, 0.5.4, 0.5.5, 0.5.5, 0.6.0, 0.6.0, 0.7.0, 0.7.0, 1.0.0, 1.0.0, 1.0.1, 1.0.1, 1.1.0, 1.1.0, 1.2.0, 1.2.0, 1.2.1, 1.2.1, 1.2.2, 1.2.2, 1.2.3, 1.2.3, 1.2.4, 1.2.4, 1.2.5, 1.2.5, 1.2.6, 1.2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, 3.1.1, 3.2.0, 3.2.0
[pipenv.exceptions.ResolutionFailure]:       Skipped pre-versions: 1.0.0a0, 1.0.0a0, 2.0.0a1, 2.0.0a1, 2.0.0b1, 2.0.0b1, 2.0.0b2, 2.0.0b2, 2.0.0b3, 2.0.0b3, 2.0.0b4, 2.0.0b4, 2.0.0b5, 2.0.0b5, 2.0.0rc1, 2.0.0rc1, 2.0.0rc2, 2.0.0rc2, 3.0.0a1, 3.0.0a1, 3.0.0b1, 3.0.0b1, 3.0.0b2, 3.0.0b2, 3.0.0b3, 3.0.0b3, 3.0.0b4, 3.0.0b4, 3.0.0b5, 3.0.0b5, 3.0.0b6, 3.0.0b6, 3.0.0b7, 3.0.0b7, 3.0.0b8, 3.0.0b8, 3.0.0b9, 3.0.0b9, 3.0.0b10, 3.0.0b10, 3.0.0b11, 3.0.0b11, 3.0.0b12, 3.0.0b12, 3.0.0b13, 3.0.0b13, 3.0.0b14, 3.0.0b14, 3.0.0b15, 3.0.0b15, 3.0.0b16, 3.0.0b16, 3.0.0b17, 3.0.0b17, 3.0.0b18, 3.0.0b18, 3.0.0b19, 3.0.0b19, 3.0.0b20, 3.0.0b20, 3.0.0rc1, 3.0.0rc1, 3.0.0rc2, 3.0.0rc2, 3.0.0rc3, 3.0.0rc3, 3.0.0rc4, 3.0.0rc4, 3.0.0rc5, 3.0.0rc5, 3.0.0rc6, 3.0.0rc6, 3.0.0rc7, 3.0.0rc7, 3.0.0rc8, 3.0.0rc8, 3.0.0rc9, 3.0.0rc9
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
 Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: ERROR: Could not find a version that matches marshmallow==3.0.0rc6,>=2.0.0
Tried: 0.1.0, 0.1.0, 0.2.0, 0.2.0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7, 3.0.0rc7, 3.0.0rc8, 3.0.0rc8, 3.0.0rc9, 3.0.0rc9
There are incompatible versions in the resolved dependencies.

I was able to successfully complete an install with pipenv install --dev --pre gql-next - but since gql-next isn't a prerelease package, it felt wrong.

I dug further into why the version of marshmallow was set to a prerelease in the dataclasses-json dependency that is used here.

$ pipenv graph
gql-next==0.1.1
  - click [required: >=7.0,<8.0, installed: 7.0]
  - dataclasses-json [required: >=0.2.0,<0.3.0, installed: 0.2.14]
    - marshmallow [required: ==3.0.0rc6, installed: 3.0.0rc6]    # <==== here it is
    - marshmallow-enum [required: >=1.4.1, installed: 1.5.1]
      - marshmallow [required: >=2.0.0, installed: 3.0.0rc6]
    - stringcase [required: ==1.2.0, installed: 1.2.0]
    - typing-inspect [required: >=0.4.0, installed: 0.4.0]
      - mypy-extensions [required: >=0.3.0, installed: 0.4.1]
  - graphql-core-next [required: >=1.0.0,<1.1.0, installed: 1.0.5]
  - inflection [required: >=0.3.1,<0.4.0, installed: 0.3.1]
  - jinja2 [required: >=2.10,<3.0, installed: 2.10.1]
    - MarkupSafe [required: >=0.23, installed: 1.1.1]
  - requests [required: >=2.21,<3.0, installed: 2.22.0]
    - certifi [required: >=2017.4.17, installed: 2019.9.11]
    - chardet [required: >=3.0.2,<3.1.0, installed: 3.0.4]
    - idna [required: >=2.5,<2.9, installed: 2.8]
    - urllib3 [required: >=1.21.1,<1.26,!=1.25.1,!=1.25.0, installed: 1.25.6]
  - watchdog [required: >=0.9.0,<0.10.0, installed: 0.9.0]
    - argh [required: >=0.24.1, installed: 0.26.2]
    - pathtools [required: >=0.1.1, installed: 0.1.2]
    - PyYAML [required: >=3.10, installed: 5.1.2]

Recently the dataclasses-json package upgraded their dependency on a stable version of marshmallow, would you consider a patch & release of dataclasses-json to ^0.3.3?

dataclasses-json = "^0.2.0"

Authenticated Endpoint Support

There doesn't seem to be a production-ready method of supporting authenticated API endpoints in this module. This would be a critical function for use of protected GQL endpoints.

Failure with requests 2.23.0

for requests 2.23.0
must be post_args = {'json': {'query': query}} instead of post_args = {'data': {'query': query}}

Does this package support union type fragments?

I have a .graphql file that looks like this:

query GetBook($id: UUID!) {
  book(id: $id) {
    author {
      id
      name
      ... on FantasyAuthor {
        fantasyBooksWritten
      }
      ... on SciFiAuthor {
        sciFiBooksWritten
      }
    }
  }
}

However, when I run gql run I get the following error:

Parsing /home/user/python-test/book_query.graphql ... Traceback (most recent call last):
  File "/home/user/.local/bin/gql", line 11, in <module>
    sys.exit(cli())
  File "/home/user/.local/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/user/.local/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/user/.local/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/user/.local/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/user/.local/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/user/.local/lib/python3.8/site-packages/gql/cli.py", line 99, in run
    process_file(filename, query_parser, query_renderer)
  File "/home/user/.local/lib/python3.8/site-packages/gql/cli.py", line 68, in process_file
    parsed = parser.parse(query)
  File "/home/user/.local/lib/python3.8/site-packages/gql/query_parser.py", line 243, in parse
    visit(document_ast, TypeInfoVisitor(type_info, visitor))
  File "/home/user/.local/lib/python3.8/site-packages/graphql/language/visitor.py", line 286, in visit
    result = visit_fn(visitor, node, key, parent, path, ancestors)
  File "/home/user/.local/lib/python3.8/site-packages/graphql/language/visitor.py", line 394, in leave
    result = fn(self.visitor, node, *args) if fn else None
  File "/home/user/.local/lib/python3.8/site-packages/gql/query_parser.py", line 109, in leave_selection_set
    self.pull()
  File "/home/user/.local/lib/python3.8/site-packages/gql/query_parser.py", line 70, in pull
    return self.dfs_path.pop()
IndexError: pop from empty list

wondering if anyone has seen similar issues. Thanks!

Good support for mocking responses, tests

I think this should be high in the roadmap:
Make it easy/fun for application writers to write mock gql responses, to support their tests.

This includes:

  • Check the mock used in the test matches the query & schema used.
  • Allow a mocked response to contain "don't-care" values (which the test writer knows aren't important for the specific test) and sentinel values (which the author will want to check for identity).
  • Allow a basic mocked response to be written for a test class, and then 'patched" in place for each test with specific changes.
  • Maybe automagically generate a mocked response, à la https://github.com/marak/Faker.js/ ?

Issues with DateTime ISO fields

when i run gql_run and the renderer_dataclasses.py encounters a DateTime field it generates a field:

var_name: datetime = None

when I run a query that returns a datetime object I get the following error:

File "/Users/jasper/Documents/test/test-graph-python-client/env/lib/python3.7/site-packages/dataclasses_json/core.py", line 220, in _decode_generic
    res = _get_type_cons(type_)(xs)
  File "/Users/jasper/Documents/test/test-graph-python-client/env/lib/python3.7/site-packages/dataclasses_json/core.py", line 260, in <genexpr>
    for x in xs)
  File "/Users/jasper/Documents/test/test-graph-python-client/env/lib/python3.7/site-packages/dataclasses_json/core.py", line 165, in _decode_dataclass
    infer_missing)
  File "/Users/jasper/Documents/test/test-graph-python-client/env/lib/python3.7/site-packages/dataclasses_json/core.py", line 179, in _decode_dataclass
    dt = datetime.fromtimestamp(field_value, tz=tz)
TypeError: an integer is required (got type str)

I think this is because in:

if field.type == 'DateTime':
suffix = '= DATETIME_FIELD'
field_type = 'datetime'
if field.nullable:
suffix = f'= {field.default_value}'
buffer.write(f'{field.name}: {field_type} {suffix}')

suffix is being overwritten if the field is nullable and DATETIME_FIELD isn't being used.

Is this client production ready for use?

Hi,

I was looking for python client to call our apollo graphql server. Is this client production ready for use or should we still use gql? What are major differences?

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.