相关疑难解决方法(0)

Interface 扩展了 GraphQL Schema 中的多个接口

在 GraphQL 中,一个接口是否可以扩展多个其他接口?
我需要这样的东西:

interface A
{
   valueA: String
}

interface B
{
   valueB: String
}

interface C extend interface A & B
{
   valueA: String
   valueB: String
}

type D implements C{
   valueA: String
   valueB: String
}

Run Code Online (Sandbox Code Playgroud)

提供的解决方案是否可以在GraphQL中实现多个接口?指一种类型实现多个接口,而不是一种接口扩展多个接口

inheritance multiple-inheritance graphql

5
推荐指数
1
解决办法
1万
查看次数

在graphql中实现多个接口

我正在使用中继编译器,它不允许我编译具有实现多个接口的类型的模式.我做了一个小测试项目:

的package.json

{
  "scripts": {
    "relay": "relay-compiler --src ./ --schema schema.graphqls"
  },
  "dependencies": {
    "react-relay": "1.5.0"
  },
  "devDependencies": {
    "relay-compiler": "1.5.0"
  }
}
Run Code Online (Sandbox Code Playgroud)

schema.graphqls

interface First {
    a: String
}

interface Second {
    b: String
}

type Something implements First, Second {
    a: String
    b: String
}
Run Code Online (Sandbox Code Playgroud)

test.js

import { graphql } from "react-relay";

graphql`fragment Test_item on Something {
    a
    b
}`;
Run Code Online (Sandbox Code Playgroud)

如果你用npm run relay运行它(在npm install之后),你会得到错误:

Error: Error loading schema. Expected the schema to be a .graphql or a .json …
Run Code Online (Sandbox Code Playgroud)

relay reactjs graphql relaymodern

3
推荐指数
1
解决办法
1059
查看次数