graphql / graphql-js

A reference implementation of GraphQL for JavaScript
http://graphql.org/graphql-js/
MIT License
20.08k stars 2.03k forks source link

Collection of libraries and how they import from `graphql` #4074

Open phryneas opened 6 months ago

phryneas commented 6 months ago

In the April meeting of the graphql-js-wg, there was discussion about bundling changes in the graphql package (https://github.com/graphql/graphql-js/issues/4062). As these changes would also add an exports field, @benjie suggested that we might want to have a restrictive set of exports entry points (only graphql, maybe one or two more?), to discourage from deep-importing from implementation details we do not consider the public interface of the library and which would result in uninteded breaking changes upon e.g. code reorganization.

In this issue, we want to collect libraries and how they are importing from graphql, to ensure that this is a feasible idea so we can discuss this further in the next graphql-js-wg meeting.

If you are generally opposed to a change like this, this issue (or the next WG meeting) are a good place to write your concerns down :)

Please copy-paste this template into a comment and fill it out:

## `<library_name>`

### Where do you import from in your library?

* `graphql`

### (If you use deep imports) why do you use deep imports?

### Would it be okay for you only import from `graphql`, too?

* [ ] yes
* [ ] no
phryneas commented 6 months ago

@apollo/client

Where do you import from in your library?

(If you use deep imports) why do you use deep imports?

Would it be okay for you only import from graphql, too?

phryneas commented 6 months ago

graphql-tag

Where do you import from in your library?

(If you use deep imports) why do you use deep imports?

Maybe for historical reasons, but everything we import is also exported from graphql itself.

Would it be okay for you only import from graphql, too?

benjie commented 6 months ago

grafast

Where do you import from in your library?

(If you use deep imports) why do you use deep imports?

Would it be okay for you only import from graphql, too?

trevor-scheer commented 6 months ago

@apollo/server

Where do you import from in your library?

(If you use deep imports) why do you use deep imports?

Would it be okay for you only import from graphql, too?

kamilkisiela commented 6 months ago

graphql-hive

Where do you import from in your library?

(If you use deep imports) why do you use deep imports?

Would it be okay for you only import from graphql, too?

n1ru4l commented 6 months ago

graphql-yoga

Where do you import from in your library?

(If you use deep imports) why do you use deep imports?

See comments behind the import - we only use them in tests for testing specific features of the GraphQL server

Would it be okay for you only import from graphql, too?

n1ru4l commented 6 months ago

@envelop/fragment-arguments

Where do you import from in your library?

(If you use deep imports) why do you use deep imports?

Types for Parser and Lexer for extending and adding new functionality

Would it be okay for you only import from graphql, too?

enisdenjo commented 6 months ago

graphql-http

Where do you import from in your library?

(If you use deep imports) why do you use deep imports?

Would it be okay for you only import from graphql, too?

enisdenjo commented 6 months ago

graphql-sse

Where do you import from in your library?

(If you use deep imports) why do you use deep imports?

Would it be okay for you only import from graphql, too?

enisdenjo commented 6 months ago

graphql-ws

Where do you import from in your library?

(If you use deep imports) why do you use deep imports?

Would it be okay for you only import from graphql, too?

saihaj commented 6 months ago

graphql-codegen

Where do you import from in your library?

(If you use deep imports) why do you use deep imports?

Would it be okay for you only import from graphql, too?

dariuszkuc commented 6 months ago

@apollo/composition

Where do you import from in your library?

(If you use deep imports) why do you use deep imports?

N/A

Would it be okay for you only import from graphql, too?

dariuszkuc commented 6 months ago

@apollo/federation-internals

Where do you import from in your library?

(If you use deep imports) why do you use deep imports?

Used for SDL validations.

Would it be okay for you only import from graphql, too?

dariuszkuc commented 6 months ago

@apollo/gateway

Where do you import from in your library?

(If you use deep imports) why do you use deep imports?

Use getVariableValues while parsing the request.

Would it be okay for you only import from graphql, too?

dariuszkuc commented 6 months ago

@apollo/query-planner

Where do you import from in your library?

(If you use deep imports) why do you use deep imports?

N/A

Would it be okay for you only import from graphql, too?

dariuszkuc commented 6 months ago

@apollo/subgraph

Where do you import from in your library?

(If you use deep imports) why do you use deep imports?

Used for SDL validations.

Would it be okay for you only import from graphql, too?

jasonkuhrt commented 6 months ago

Thanks @phryneas I just pushed a fix that removed deep imports wherever I can. The following is up to date with that.


graphql-request

Where do you import from in your library?

import { ... } from 'graphql'
import { type ObjMap } from 'graphql/jsutils/ObjMap.js'

(If you use deep imports) why do you use deep imports?

To access ObjMap which is the type of some data structures exposed by graphql library.

Would it be okay for you only import from graphql, too?

[1] Except for ObjMap type which is currently not exported from graphql. Worst case I could copy the type into my package.

AnthonyMDev commented 6 months ago

apollo-ios

Where do you import from in your library?

(If you use deep imports) why do you use deep imports?

To access validateSDL (validation) and isNode (ast)

Would it be okay for you only import from graphql, too?

dylanaubrey commented 6 months ago

graphql-box

Where do you import from in your library?

(If you use deep imports) why do you use deep imports?

Would it be okay for you only import from graphql, too?

benjie commented 4 months ago

A new library I'm working on needs isNode to be exported (currently imported from graphql/language/ast).